脚本基于注释的帮助
<#
.SYNOPSIS
Reads a CSV file and filters it.
.DESCRIPTION
The ReadUsersCsv.ps1 script reads a CSV file and filters it on the 'UserName' column.
.PARAMETER Path
Specifies the path of the CSV input file.
.INPUTS
None. You cannot pipe objects to ReadUsersCsv.ps1.
.OUTPUTS
None. ReadUsersCsv.ps1 does not generate any output.
.EXAMPLE
C:\PS> .\ReadUsersCsv.ps1 -Path C:\Temp\Users.csv -UserName j.doe
#>
Param
(
[Parameter(Mandatory=$true,ValueFromPipeline=$false)]
[System.String]
$Path,
[Parameter(Mandatory=$true,ValueFromPipeline=$false)]
[System.String]
$UserName
)
Import-Csv -Path $Path | Where-Object -FilterScript {$_.UserName -eq $UserName}
可以通过运行 Get-Help -Name ReadUsersCsv.ps1 -Full
来显示上面的脚本文档: