)] [Alias("ProcessName")] public string[] Name { get { return processNames; } set { processNames = value; } } private string[] processNames; VB 複製 <Parameter(Position:=0, ParameterSetName:="ProcessName", _ Mandatory:=True, _ ValueFromPipeline:=True, ValueFromPipelineByPropertyName...
param( [Parameter(Mandatory, ParameterSetName="Computer")] [string[]]$ComputerName, [Parameter(Mandatory, ParameterSetName="User")] [string[]]$UserName, [Parameter()] [switch]$Summary ) 每個自變數中只能指定一個ParameterSetName值,而且每個ParameterSetName屬性中只能指定一個自變數。 若...
To create a strongly typed array, that is, an array that can contain only values of a particular type, cast the variable as an array type, such as string[], long[], or int32[]. To cast an array, precede the variable name with an array type enclosed in brackets. For example:Power...
Add helper in EnumSingleTypeConverter to get enum names as array (#17785) (Thanks @fflaten!) Return correct FileName property for Get-Item when listing alternate data streams (#18019) (Thanks @kilasuit!) Add -ExcludeModule parameter to Get-Command (#18955) (Thanks @MartinGC94!) Update Nam...
TheSelect-Stringcommand in the function uses thePathandPatternparameters. ThePathparameter uses the$PSHelpvariable to get the path. ThePatternparameter uses the stringAbout_as the search criteria. To run the function, typeSearch-Help. The function'sSelect-Stringcommand displays the output in the ...
function <name> (<parameter list>) {<statement list>} The format of the parameter list is identical to that of theparamstatement. The above script can be converted to a function as follows function foo([string]$foo = "foo", [string]$bar = "bar") ...
The values can be passed to the Option parameter as an array of values or as a comma-separated string of those values. The cmdlet will combine the values using a binary-OR operation. Passing values as an array is the simplest option and also allows you to use tab-completion on the ...
First, I use$array | Get-Randomto get a random country. This will return an element from the array, but I need it to be a datatype of string rather than a generic object. So I wrap the result ofGet-Randomin$( )to make PowerShell evaluate it as an object. Then I can call the...
Type:SwitchParameter Position:Named Default value:None Required:False Accept pipeline input:False Accept wildcard characters:False -Include Specifies, as a string array, an item or items that this cmdlet includes in the operation. The value of this parameter qualifies thePathparameter. Enter a path...
Add helper in EnumSingleTypeConverter to get enum names as array (#17785) (Thanks @fflaten!) Return correct FileName property for Get-Item when listing alternate data streams (#18019) (Thanks @kilasuit!) Add -ExcludeModule parameter to Get-Command (#18955) (Thanks @MartinGC94!) Update Nam...