Powershell - Format-List Cmdlet
cmdlet
Format-List cmdlet can be used to formats the output as a list of properties where a property appears on a new line.
In these examples, we're see the Format-List cmdlet in action.
Example 1
In this example, first we've a file test.txt in D:\temp\test with content "Welcome to TutorialsPoint.Com" and test1.txt with content "Hello World!" and "Welcome to TutorialsPoint.Com" in two lines.
Get the file details in a variable.
$A = Get-ChildItem D:\temp\test\*.txt
Get the file details using Format-List cmdlet.
Format-List -InputObject $A
Output
You can see following output in PowerShell console.
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:
Example 2
Get the list of services
Type the following command in PowerShell ISE Console
Get-Service | Format-List
Output
You can see following output in PowerShell console.
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 ...