【发布时间】:2013-08-09 05:48:51
【问题描述】:
假设我调用 Get-Service 并希望分配一个新列 ID 与打印递增整数的 cmdlet 输出,以便:
ID Status Name DisplayName
-- ------ ---- -----------
0 Running AdobeARMservice Adobe Acrobat Update Service
1 Stopped AeLookupSvc Application Experience
2 Stopped ALG Application Layer Gateway Service
我现在正在尝试使用Select-Object 添加此列,但我不太明白如何在这种表达式中迭代变量。这是我得到的:
Get-Service |
Select-Object @{ Name = "ID" ; Expression= { } }, Status, Name, DisplayName |
Format-Table -Autosize
有没有办法在Expression= { } 中迭代整数,还是我解决这个问题的方式不对?
【问题讨论】:
标签: powershell cmdlets