PowerShell - Format-Wide Cmdlet



cmdlet

Format-Wide cmdlet 可用於將輸出格式化為一個包含每個物件一個屬性的表。

在這些示例中,我們將看到 Format-Wide cmdlet 的實際操作。

示例 1

在此示例中,首先我們有一個檔案 test.txt,位於 D:\temp\test,內容為“Welcome to TutorialsPoint.Com”;test1.txt,內容為“Hello World!”和“Welcome to TutorialsPoint.Com”,分兩行顯示。

在變數中獲取檔案詳細資訊。

$A = Get-ChildItem D:\temp\test\*.txt

使用 Format-Wide cmdlet 獲取檔案詳細資訊。

Format-Wide -InputObject $A

輸出

你可以在 PowerShell 控制檯中看到以下輸出。

Directory: D:\temp\test
   test.txt                                 test1.txt           

示例 2

獲取所需屬性。

在 PowerShell ISE 控制檯中鍵入以下命令

Format-Wide -InputObject $A -Property -Property Length

輸出

你可以在 PowerShell 控制檯中看到以下輸出。

Directory: D:\temp\test
   31                                       44
powershell_advanced_cmdlets.htm
廣告
© . All rights reserved.