Chi*_*ago 3 syntax powershell alias
在PowerShell cmdlet中声明别名的文档显示以下内容:
Function Get-SomeValue {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true,Position=0)]
[Alias("MachineName")]
[string[]]$ComputerName
)
Get-WmiObject -Class Win32_ComputerSystem -ComputerName $ComputerName
}
Run Code Online (Sandbox Code Playgroud)
我用什么语法来创建多个别名?
[Alias("one","two","three)][Alias("one")][Alias("two")][Alias("three")]PS使用时Get-Help,应该显示别名在哪里?到目前为止,我没有看到它们.
[Alias("one")][Alias("two")]和[Alias("one", "two")]两个工作.当您显示参数的帮助时,您会看到别名:
PS C:\> Get-Help Get-SomeValue -Parameter computername
-ComputerName <string[]>
Required? true
Position? 0
Accept pipeline input? true (ByValue)
Parameter set name (All)
Aliases one, two
Dynamic? false
| 归档时间: |
|
| 查看次数: |
654 次 |
| 最近记录: |