如果使用Get-WmiObject 獲取系統(tǒng)中的服務(wù),為了排版可能會(huì)也會(huì)使用Format-Table對(duì)結(jié)果進(jìn)行表格排版。
PS C:Powershell> Get-WmiObject Win32_Service | Format-Table status,DisplayName
-AutoSize
status DisplayName
------ -----------
OK Adobe Acrobat Update Service
OK Application Experience
OK Application Layer Gateway Service
OK Application Host Helper Service
OK Application Identity
OK Application Information
OK Application Management
OK ASP.NET State Service
PS C:Powershell> Get-Process iexplore
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
883 29 14728 22432 181 34.26 4300 iexplore
771 28 55552 129152 425 8.56 5732 iexplore
1216 51 104324 143916 539 572.41 5912 iexplore
801 25 49200 25372 285 5.99 6252 iexplore
691 25 57564 95796 333 8.08 6388 iexplore
1256 38 85848 127012 379 20.37 7856 iexplore
PS C:Powershell> Get-Process iexplore | ForEach-Object {$_.kill()}
PS C:Powershell> Get-Process iexplore
Get-Process : 找不到名為“iexplore”的進(jìn)程。請(qǐng)驗(yàn)證該進(jìn)程名稱,然后再次調(diào)用 cmdlet。
所在位置 行:1 字符: 12
+ Get-Process iexplore
+ CategoryInfo : ObjectNotFound: (iexplore:String) [Get-Process],
ProcessCommandException
+ FullyQualifiedErrorId : NoProcessFoundForGivenName,Microsoft.PowerShell.
Commands.GetProcessCommand