Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Variables “美元”是什么意思&引用;在PowerShell中是什么意思_Variables_Powershell_Error Handling_Powershell 2.0 - Fatal编程技术网

Variables “美元”是什么意思&引用;在PowerShell中是什么意思

Variables “美元”是什么意思&引用;在PowerShell中是什么意思,variables,powershell,error-handling,powershell-2.0,Variables,Powershell,Error Handling,Powershell 2.0,我对PowerShell很陌生。在查找有关错误处理的信息时,我发现了许多有关使用“$?”的参考资料 我知道这与错误有关,但到底是什么?我在哪里可以读到更多关于它的信息 我所有的谷歌搜索都没有找到任何内容。来自: 错误和调试:最后一个命令的成功或失败状态可以通过检查$ 例如: > Get-Content file-that-exists.txt Hello world > Write-Host $? True > Get-Content file-that-does-not-ex

我对PowerShell很陌生。在查找有关错误处理的信息时,我发现了许多有关使用“$?”的参考资料

我知道这与错误有关,但到底是什么?我在哪里可以读到更多关于它的信息

我所有的谷歌搜索都没有找到任何内容。

来自:

错误和调试:最后一个命令的成功或失败状态可以通过检查$

例如:

> Get-Content file-that-exists.txt
Hello world
> Write-Host $?
True
> Get-Content file-that-does-not-exist.txt
Get-Content : Cannot find path 'C:\file-that-does-not-exist.txt' because it does not exist.
At line:1 char:1
+ Get-Content file-that-does-not-exist.txt
+ ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\file-that-does-not-exist.txt:String) [Get-Content], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand
> Write-Host $?
False

问了这个问题后,我发现了命令 “获取帮助-关于自动变量的名称”


这提供了有关powershell中每个自动变量的信息,非常有用

相关帖子:你知道有哪个地方有更多关于它的文档吗?或者它只是简单到不需要更多的文档?@SSAdministrator就是这么简单,它的布尔值。因此,您可以以各种有趣的方式使用它,例如“If(!($?){Create File$SomeFile}该命令对我不起作用
Get-Help在本次会话的帮助文件中找不到关于自动变量的信息。
这是Windows 8上的PowerShell 3。@Klashoutbourn,您运行了
更新帮助
?它适用于我在v3/Win7上运行。@Klashoutbourn抱歉,我应该补充一点,我在PowerShell 2.0上运行了它,而且我在列表的末尾使用了命令“Get Help-Name*”,它有帮助文件,描述了很多things@alroc谢谢,这很有帮助!这也是在线的