您现在的位置是:网站首页> 编程资料编程资料
PowerShell中查询错误编号信息的2个方法_PowerShell_
2023-05-26
363人已围观
简介 PowerShell中查询错误编号信息的2个方法_PowerShell_
有时候,一些本地命令,比如net.exe,在执行过程中,会返回数字编号形式的错误信息。很郁闷的是,我们不知道这些数字代表什么意思。以前,我们可以使用如下的方式去获取数字代表的信息:
复制代码 代码如下:
PS> net helpmsg 3534
The service did not report an error.
PS> net helpmsg 1
Incorrect function.
PS> net helpmsg 4323
The transport cannot access the medium.
其实有一个更好的方法,那就是使用winrm.exe,它不仅可以实现上面的功能,而且还要更加强大!同样的,看看对上面三个错误的翻译:
复制代码 代码如下:
PS> winrm helpmsg 3534
The service did not report an error.
PS> winrm helpmsg 1
Incorrect function.
PS> winrm helpmsg 4323
The transport cannot access the medium.
OK,看到了吧,结果是一样的。其实,net.exe只能翻译中一个特定规范内的错误信息(具体怎么样一个特定的规范,洪哥也不是很清楚),而winrm.exe则要更加强大,比如它可以转换“特定的远程”错误代码:
复制代码 代码如下:
PS> winrm helpmsg 0x80338104
The WS-Management service cannot process the request. The WMI service returned an 'access denied' error.
PS> net helpmsg 0x80338104
The syntax of this command is:
NET HELPMSG
message#
上面可以看出来,winrm.exe正确的翻译出了0x80338104的错误信息,而net.exe没有做到。其实,这个命令可能跟PowerShell没有什么直接的关系,但也算是一个Shell命令吧,我们可以使用它去翻译任何低级的API错误代码,并且坚定的相信它得到的结果。
您可能感兴趣的文章:
相关内容
- PowerShell中定义多个变量并赋值的例子_PowerShell_
- PowerShell中把相对路径转换为绝对路径的2个方法_PowerShell_
- PowerShell移动目录中指定文件的方法(非全部文件)_PowerShell_
- PowerShell命令中包含空格如何运行?_PowerShell_
- PowerShell脚本监控文件夹变化实例_PowerShell_
- Win8系统中使用PowerShell安装APPX应用命令介绍_PowerShell_
- PowerShell中使用通配符匹配文件路径的例子_PowerShell_
- PowerShell中按文件后缀过滤的实现代码_PowerShell_
- Powershell Profiles配置文件的存放位置介绍_PowerShell_
- PowerShell脚本中控制Windows DNS服务的方法_PowerShell_
