1

我正在使用 PowerShell ServerManager cmdlet,但无法找到安装命令的退出代码的完整列表。

$feature = Add-WindowsFeature NET-Framework-Core
exit $feature.ExitCode

我可以期望 ExitCode 包含哪些值?

4

2 回答 2

3

我从未使用过这个 cmdlet,但根据@vmrob 的初始回答,它似乎是枚举类型ExitCode的实例。Microsoft.Windows.ServerManager.Commands.FeatureOperationExitCode

您应该能够获得这样的可能值列表:

[enum]::GetNames( [Microsoft.Windows.ServerManager.Commands.FeatureOperationExitCode] )
于 2014-12-18T23:54:26.957 回答
1

当前版本的 PowerShell cmdlet 可能充当了已弃用的servermanagercmd.exe. 如果是这种情况,那么此处列出的退出代码应该适用:

http://technet.microsoft.com/en-us/library/cc733119.aspx

到目前为止我遇到的退出代码匹配:

具有已安装的功能

PS C:\> $feature = Add-WindowsFeature NET-Framework-Core
PS C:\> $feature.ExitCode
NoChangeNeeded
PS C:\> $feature.ExitCode.value__
1003

由于需要重新启动而无法安装功能时

这可能在 Windows 更新运行之后但在计算机重新启动之前发生。

PS C:\> $feature = Add-WindowsFeature NET-Framework-Core
PS C:\> $feature.ExitCode
FailedRestartRequired
PS C:\> $feature.ExitCode.value__
1001

关于成功

PS C:\> $feature = Add-WindowsFeature NET-Framework-Core
PS C:\> $feature.ExitCode
Success
PS C:\> $feature.ExitCode.value__
0
于 2014-12-18T23:30:41.140 回答