PS C:\Users\Denny> Get-Help Format-List -Examples
名称
Format-List
摘要
Formats the output as a list of properties in which each property appears on a new line.
-------------------------- EXAMPLE 1 --------------------------
PS C:\> get-service | format-list
This command formats information about services on the computer as a list. By default, the services are formatted a
s a table. The Get-Service cmdlet gets objects representing the services on the computer. The pipeline operator (|)
passes the results through the pipeline to Format-List. Then, the Format-List command formats the service informat
ion in a list and sends it to the default output cmdlet for display.
-------------------------- EXAMPLE 2 --------------------------
PS C:\> $a = get-childitem $pshome\*.ps1xml
PS C:\>format-list -InputObject $a
These commands display information about the PS1XML files in the Windows PowerShell directory as a list.
The first command gets the objects representing the files and stores them in the $a variable.
The second command uses Format-List to format information about objects stored in $a. This command uses the InputOb
ject parameter to pass the variable to Format-List, which then sends the formatted output to the default output cmd
let for display.
-------------------------- EXAMPLE 3 --------------------------
PS C:\> get-process | format-list -property name, basepriority, priorityclass
This command displays the name, base priority, and priority class of each process on the computer. It uses the Get-
Process cmdlet to get an object representing each process. The pipeline operator (|) passes the process objects thr
ough the pipeline to Format-List. Format-List formats the processes as a list of the specified properties. The "Pro
perty" parameter name is optional, so you can omit it.
-------------------------- EXAMPLE 4 --------------------------
PS C:\> get-process winlogon | format-list -property *
This command displays all of the properties of the Winlogon process. It uses the Get-Process cmdlet to get an objec
t representing the Winlogon process. The pipeline operator (|) passes the Winlogon process object through the pipel
ine to Format-List. The command uses the Property parameter to specify the properties and the * to indicate all pro
perties. Because the name of the Property parameter is optional, you can omit it and type the command as: "format-l
ist *". Format-List automatically sends the results to the default output cmdlet for display.