例2

获取服务列表

Get-Service | Format-List
Powershell-格式列表Cmdlet

输出

我们可以在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控制台中看到以下输出。

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:     
                 OroirnalFilename: 
                 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:     
                 OroirnalFilename: 
                 FileVersion:      
                 FileDescription:  
                 Product:          
                 ProductVersion:   
                 Debug:            False
                 Patched:          False
                 PreRelease:       False
                 PrivateBuild:     False
                 SpecialBuild:     False
                 Language:

cmdlet

Format List cmdlet可用于将输出格式化为属性列表,其中属性出现在新行上。

例1

获取变量中的文件详细信息。

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

使用Format List cmdlet获取文件详细信息。

Format-List -InputObject $A
日期:2019-08-20 13:51:06 来源:oir作者:oir