指令碼基於註釋的幫助
<#
.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
來顯示上面的指令碼文件: