我能用Windows PowerShell做什麼:把資料顯示成一個列表
阿新 • • 發佈:2019-01-26
注:本篇文章,未在聯絡作者以及得到許可的情況下, 禁止以任何形式進行轉載。
把資料顯示成一個列表
許多cmdlets (Get-Service,如這個命令),顯示資訊的表格形式。也許有時候,當你想把資料資訊顯示成一個列表的時候(特別是如果這個表格有太多的欄目,以很好的適合螢幕)。也許正如你所期望的,這個format-List cmdlet在這裡作為一個列表的形式來幫你顯示資訊。首先,這裡用Get-Service cmdlet預設輸出,像這個樣子: Status Name DisplayName
---------------------
Running AdobeActiveFile... Adobe Active File Monitor V4
Running ALG Application Layer Gateway Service
當你通過用Format-List獲得輸出時就像這個樣子:
Name : SpoolerDisplayName : Print Spooler
Status : Running
DependentServices : {}
ServicesDependedOn : {RPCSS}
CanPauseAndContinue : False
CanStop : True
ServiceType : Win32OwnProcess, InteractiveProcess 大家可以看到,任何時候你使用Get-Service只要三個屬性值就好在Windows PowerShell中顯示一個表格。用Get-Service時一個方法可以得到所有有效的屬性以及他們的值並且用Format-List輸出。
這是一個很好的問題:我們如何用Format-List輸出格式名單?這裡: Get-Service | Format-List
它是那麼的簡單。