在PowerShell 2.0 中,如何你要运行以数字开头的命令或者函数,需要在前面加上“&”符号,例如,定义一个函数名为 3gumaolu:
PS D:\> Function 3GuMaolu()
>> {
>> Write-Host "三顾茅庐"
>> }
>>
PS D:\> 3GuMaolu
数字常量无效: 3。
所在位置 行:1 字符: 2
+ 3 <<<< GuMaolu
    + CategoryInfo          : ParserError: (3:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : BadNumericConstant
PS D:\> & 3GuMaolu
三顾茅庐
但是在PowerShell 3.0 中,已经不需要多此一举了,直接运行也能识别,从小处就可发现PowerShell 一直在朝着易用性方向进化。
本文链接: https://www.pstips.net/powershell-launching-commands-that-start-with-numbers.html
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!
                                      请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!
