-<parameter_name> <parameter_value> -<parameter_name>:<parameter_value> 參數的名稱前面加上連字元 (-),它會向PowerShell發出訊號,指出連字元後面的單字是參數名稱。 參數名稱和值可以以空格或冒號字元分隔。 某些參數不需要或接受參數值。 其他參數需要值,但不需要命令中的參數名稱。
$PSDefaultParameterValues = @{"*:Verbose"=$True} Use an array for the default valueIf a parameter can accept multiple values, an array, you can set multiple values as the default values. The default value of the Invoke-Command:ComputerName key is set to an array value of Serv...
false -Name <String[]> Specifies the service names for the service to be started. The parameter name is optional. You can use Name or its alias, ServiceName, or you can omit the parameter name. Required? true Position? 0 Default value None Accept pipeline input? True (ByPropertyName, By...
The parameter name is optional. You can use Name or its alias, ServiceName, or you can omit the parameter name. Required? true Position? 0 Default value None Accept pipeline input? True (ByPropertyName, ByValue) Accept wildcard characters? false 通过管道将对象发送到 Start-Service 时,Power...
public string Parameter1; [Parameter(Mandatory = true, ValueFromPipeline = true)] public string InputObject; protected override void ProcessRecord() { if ( Parameter1 != null ) { WriteObject(Parameter1 + ":" + InputObject); } else { ...
Optional parameters have a default value, which is the value that is used or assumed when the parameter is not specified in the command. For example, the default value of theComputerNameparameter of many cmdlets is the name of the local computer. As a result, the local computer name is us...
enum <enum-name> { [= <int-value>] ... } exitCauses PowerShell to exit a script or a PowerShell instance.Syntax:Syntax Kopēt exit exit <exitcode> When you use pwsh with the File parameter, the .ps1 (script) file itself should include instructions for handling any errors or excep...
FunctionTest-ScriptCmdlet{ [CmdletBinding(SupportsShouldProcess=$true)]param($Parameter1)begin{}process{}end{} } begin This block is used to provide optional one-time preprocessing for the function. The PowerShell runtime uses the code in this block once for each instance of the function in th...
Set-PSReadLineOption-Colors@{ Command ='Magenta'Number ='DarkGray'Member ='DarkGray'Operator ='DarkGray'Type ='DarkGray'Variable ='DarkGreen'Parameter ='DarkGreen'ContinuationPrompt ='DarkGray'Default ='DarkGray'} 示例5:设置多种类型的颜色值 ...
True (ByValue, ByPropertyName) -ProfileLocation <String> Used to specify the name and location of the ini-format credential file (shared with the AWS CLI and other AWS SDKs)If this optional parameter is omitted this cmdlet will search the encrypted credential file used by the AWS SDK for ...