49
您可以通过输入exit
来退出PowerShell。到现在为止还挺好。但究竟是什么呢?PowerShell中的“退出”究竟是什么?
PS Home:\> gcm exit
Get-Command : The term 'exit' is not recognized as the name of a cmdlet, function, script file, or operable program. Ch
eck the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:4
+ gcm <<<< exit
+ CategoryInfo : ObjectNotFound: (exit:String) [Get-Command], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand
因此,它既不是cmdlet,函数,脚本或程序。它留下的问题究竟是什么。
这不幸也意味着,一个不能创建别名exit
:
PS Home:\> New-Alias ^D exit
PS Home:\> ^D
Cannot resolve alias '♦' because it refers to term 'exit', which is not recognized as a cmdlet, function, operable prog
ram, or script file. Verify the term and try again.
At line:1 char:2
+ ♦ <<<<
+ CategoryInfo : ObjectNotFound: (♦:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : AliasNotResolvedException
是否有任何这是没有命令更多这样的命令?
ETA:仅供参考:我知道我可以简单地将它包装成函数。我的个人资料有行
# exit with Ctrl+D
iex "function $([char]4) { exit }"
其中。我的问题只是要知道这个命令是什么。
据'获取帮助退出-PSSession' _You也可以使用Exit关键字来结束交互式会话。效果和使用Exit-PSSession._一样。所以它也说'Exit'是一个关键字。但是,看起来这个引用并不意味着'exit'和'exit-PSSession'在所有情况下都是等价的。 exit关键字可以与可以转换为'[int]'的参数一起使用,在这种情况下,该数字将是退出代码。例如'出口42'。 – 2015-10-14 09:20:24