Powershell-cmdlets-format-list

提供:Dev Guides
移動先:案内検索

Powershell-Format-Listコマンドレット

コマンドレット

*Format-List* コマンドレットを使用して、プロパティを新しい行に表示するプロパティのリストとして出力をフォーマットできます。

これらの例では、Format-Listコマンドレットが動作していることがわかります。

例1

この例では、最初にD:\ temp \ testに「Welcome to finddevguides.Com」という内容のtest.txtファイルと「Hello World!」という内容のtest1.txtファイルがあります。 「Welcome to finddevguides.Com」を2行で表示します。

変数でファイルの詳細を取得します。

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

Format-Listコマンドレットを使用してファイルの詳細を取得します。

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
...