- Powershell 教程
- Powershell-主頁
- Powershell-概述
- Powershell-環境設定
- Powershell-cmdlet
- Powershell-檔案和資料夾
- Powershell-日期和定時器
- Powershell-檔案 I/O
- PowerShell-高階 cmdlet
- PowerShell-編寫指令碼
- PowerShell-特殊變數
- PowerShell-運算子
- PowerShell-迴圈
- PowerShell-條件
- PowerShell-陣列
- PowerShell-雜湊表
- PowerShell-Regex
- PowerShell-平引號
- PowerShell-括號
- PowerShell-別名
- Powershell-有用資源
- PowerShell-快速指南
- PowerShell-有用資源
- PowerShell-討論
Powershell-Format-List cmdlet
cmdlet
Format-List cmdlet 可用於將輸出格式化為屬性列表,其中屬性顯示在單獨一行上。
在以下示例中,我們看到了Format-List cmdlet 的實際應用。
示例 1
在此示例中,首先我們在 D:\temp\test 中擁有一個檔案 test.txt,其內容為“Welcome to TutorialsPoint.Com”,並且在 test1.txt 中以兩行形式擁有內容:“Hello World!”和“Welcome to TutorialsPoint.Com”。
在變數中獲取檔案詳細資訊。
$A = Get-ChildItem D:\temp\test\*.txt
使用 Format-List cmdlet 獲取檔案詳細資訊。
Format-List -InputObject $A
輸出
你可以在 PowerShell 控制檯中看到以下輸出。
Directory: D:\temp\test
Name : test.txt
Length : 31
CreationTime : 4/4/2018 4:48:38 PM
LastWriteTime : 4/11/2018 4:40:15 PM
LastAccessTime : 4/4/2018 4:48:38 PM
VersionInfo : File: D:\temp\test\test.txt
InternalName:
OriginalFilename:
FileVersion:
FileDescription:
Product:
ProductVersion:
Debug: False
Patched: False
PreRelease: False
PrivateBuild: False
SpecialBuild: False
Language:
Name : test1.txt
Length : 44
CreationTime : 4/12/2018 6:54:48 PM
LastWriteTime : 4/12/2018 6:56:21 PM
LastAccessTime : 4/12/2018 6:54:48 PM
VersionInfo : File: D:\temp\test\test1.txt
InternalName:
OriginalFilename:
FileVersion:
FileDescription:
Product:
ProductVersion:
Debug: False
Patched: False
PreRelease: False
PrivateBuild: False
SpecialBuild: False
Language:
示例 2
獲取服務列表
在 PowerShell ISE 控制檯中鍵入下列命令
Get-Service | Format-List
輸出
你可以在 PowerShell 控制檯中看到以下輸出。
Name : AdobeARMservice
DisplayName : Adobe Acrobat Update Service
Status : Running
DependentServices : {}
ServicesDependedOn : {}
CanPauseAndContinue : False
CanShutdown : False
CanStop : True
ServiceType : Win32OwnProcess
Name : AdobeFlashPlayerUpdateSvc
DisplayName : Adobe Flash Player Update Service
Status : Stopped
DependentServices : {}
ServicesDependedOn : {}
CanPauseAndContinue : False
CanShutdown : False
CanStop : False
ServiceType : Win32OwnProcess
...
powershell_advanced_cmdlets.htm
廣告