您也可以為 Cmdlet 或進階函式的任何參數設定自定義預設值。 如需設定自定義預設值的相關信息,請參閱about_Parameters_Default_Values。 參數屬性數據表 當您使用 Cmdlet 的Full、Parameter或Get-Help參數時,Get-Help會顯示參數屬性數據表,其中包含參數的詳細資訊。
param( [Parameter(Mandatory)] [ValidateLength(1,10)] [string[]]$ComputerName ) 在下列範例中,變數 $text 的值長度必須至少為一個字元,且最多 10 個字元。PowerShell 複製 [ValidateLength(1,10)] [string] $text = 'valid' ValidatePattern 驗證屬性ValidatePattern 屬性會指定與參數或變...
ValidParamSetValues Property Reference Feedback Definition Namespace: Microsoft.PowerShell.Commands.ShowCommandExtension Assembly: Microsoft.PowerShell.Commands.Utility.dll Package: Microsoft.PowerShell.Commands.Utility v7.4.0 The possible values of this parameter. C# 複製...
PS> 1usgb At line:1 char:6 + 1usgb + ~ The numeric constant 1usgb is not valid. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : BadNumericConstant 不過,具有無效語法的 1gbus 格式常值會解譯為標準裸機字串,而且可以在呼叫命令的內容中解譯為...
可以通过在命令提示符处输入$PSDefaultParameterValues来查看定义的值。 PowerShell PS>$PSDefaultParameterValuesName Value --- ---Get-WinEvent:LogNameMicrosoft-Windows-PrintService/Operational Get-*:Verbose TrueSend-MailMessage:SmtpServer Server123 可以使用...
For example, theNameparameter of theGet-Servicecmdlet accepts multiple values. The following commands are both valid: PowerShell Get-Service-Namewinrm, netlogon PowerShell $s="winrm","netlogon"Get-Service-Name$s Accepts Pipeline Input
Valid values are strings, the same as for any variable names. The following is an example of how PipelineVariable works. In this example, the PipelineVariable parameter is added to a Foreach-Object command to store the results of the command in variables. A range of numbers, 1 to 10, ar...
This parameter is functional only in on-premises Exchange. This parameter specifies the mailboxes to exclude when you use the value All for the ExchangeLocation parameter. Valid values are: A regular user mailbox. Including other types of mailboxes (for example, inactive mailboxes or Microsoft ...
(Get-Command Select-String).Parameters.Culture.Attributes.ValidValues 有关.NET CultureInfo.Name 属性的详细信息,请参阅CultureInfo.Name。 PowerShell 7 中引入了Culture参数。 类型:String Position:Named 默认值:Culture of the current PowerShell session ...
The ProgressAction parameter was added in PowerShell 7.4. The ProgressAction parameter takes one of the ActionPreference enumeration values: SilentlyContinue, Stop, Continue, Inquire, Ignore, Suspend, or Break. The valid values are as follows: Break Enters the debugger at an occurrence of the ...