param( [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [string[]]$ComputerName ) 请考虑使用此参数实现函数: PowerShell 复制 function Test-ValueFromPipelineByPropertyName{ param( [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [string[]]$ComputerName ) Write-Output -Inp...
-ClobberSwitchParameter已命名(選擇性) 指定此值時會強制為指定的輸出繫結設定值。 也支援下列常見參數: Verbose Debug ErrorAction ErrorVariable WarningAction WarningVariable OutBuffer PipelineVariable OutVariable 如需詳細資訊,請參閱關於 CommonParameters。
名称类型位置说明 -Name 字符串 1 你要设置的输出绑定的名称。 -Value Object 2 你要设置的输出绑定的值,它是从管道 ByValue 接受的。 -Clobber SwitchParameter 名为 (可选)指定了此项时,系统会强制为指定的输出绑定设置值。还支持以下常用参数:Verbose...
类型:SwitchParameter Position:Named 默认值:False 必需:False 接受管道输入:False 接受通配符:False -Path 指定要搜索的文件的路径。 允许通配符。 默认位置是本地目录。 指定目录中的文件,例如log1.txt、*.doc或*.*。 如果仅指定目录,命令将失败。
类型:SwitchParameter 别名:cf Position:Named 默认值:False 必需:False 接受管道输入:False 接受通配符:False -ConnectionURI 这是WSMan提供程序提供的动态参数。WSMan提供程序,此参数仅在 Windows 上可用。 指定WSMan 的连接终结点。 有关详细信息,请参阅New-WSManInstance。
If no parameters are used, switch behaves the same as using the Exact parameter. It performs a case-insensitive match for the value. If the value is a collection, each element is evaluated in the order in which it appears.The switch statement must include at least one condition statement....
functionAdd-PoshGitToProfile { [CmdletBinding(SupportsShouldProcess)]param( [Parameter()] [switch]$AllHosts, [Parameter()] [switch]$AllUsers, [Parameter()] [switch]$Force, [Parameter(ValueFromRemainingArguments)] [psobject[]]$TestParams)if($AllUsers-and!(Test-Administrator)) {throw'Adding posh...
Instead, you type the function name followed by the name of the switch parameter. To define a switch parameter, specify the type [switch] before the parameter name, as shown in the following example: PowerShell Copy function Switch-Item { param ([switch]$on) if ($on) { "Switch on" ...
function test-param { param( [Parameter(ParameterSetName=”p1″,Position=0)] [String] $d, [Parameter(ParameterSetName=”p2″, Position=0)] [String] $i ) switch ($PsCmdlet.ParameterSetName) { “p1” { Write-Host([DateTime]$d);break} ...
类型:SwitchParameter Position:Named 默认值:None 必需:False 接受管道输入:False 接受通配符:False -Path 指定此 cmdlet 从中获取事件的事件日志文件的路径。 在以逗号分隔的列表中输入日志文件的路径,或使用通配符来创建文件路径模式。 Get-WinEvent支持具有.evt、.evtx和.etl文件扩展名的文件。 可以在同一命令中包括...