- Powershell 教程
- Powershell-主页
- Powershell-概述
- Powershell-环境设置
- Powershell-cmdlet
- Powershell-文件和文件夹
- Powershell-日期和定时器
- Powershell-文件 I/O
- PowerShell-高级 cmdlet
- PowerShell-编写脚本
- PowerShell-特殊变量
- PowerShell-运算符
- PowerShell-循环
- PowerShell-条件
- PowerShell-数组
- PowerShell-哈希表
- PowerShell-Regex
- PowerShell-平引号
- PowerShell-括号
- PowerShell-别名
- Powershell-有用资源
- PowerShell-快速指南
- PowerShell-有用资源
- PowerShell-讨论
Powershell-Format-List cmdlet
cmdlet
Format-List cmdlet 可用于将输出格式化为属性列表,其中属性显示在单独一行上。
在以下示例中,我们看到了Format-List cmdlet 的实际应用。
示例 1
在此示例中,首先我们在 D:\temp\test 中拥有一个文件 test.txt,其内容为“Welcome to TutorialsPoint.Com”,并且在 test1.txt 中以两行形式拥有内容:“Hello World!”和“Welcome to 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
...
powershell_advanced_cmdlets.htm
广告