cmdlet
Format-List cmdlet可用于将输出格式化为属性列表,其中属性出现在新行中。
在这些示例中,我们看到了正在使用的Format-List cmdlet。
例子1
在此示例中,首先我们在D:\ temp \ test中有一个文件test.txt,内容为“ Welcome to TutorialsPoint.Com”,而在test1.txt中,内容为“ Hello World!”。和“欢迎使用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
...
seo优化_前端开发_渗透技术


