【问题标题】:Where can I find a list of exit codes and their meanings for the PowerShell ServerManager cmdlet?在哪里可以找到 PowerShell ServerManager cmdlet 的退出代码列表及其含义?
【发布时间】:2015-02-17 21:18:28
【问题描述】:

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

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

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

【问题讨论】:

    标签: powershell windows-server servermanager


    【解决方案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
    

    【讨论】:

      【解决方案2】:

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

      您应该能够获得如下可能值的列表:

      [enum]::GetNames( [Microsoft.Windows.ServerManager.Commands.FeatureOperationExitCode] )
      

      【讨论】:

      • 我实际上在那里回答了我自己的问题,并且正在寻找一种更好的方法来找到这些东西。我还是 PowerShell 的新手,这看起来像是回答了一个我不知道如何问的不同问题。谢谢!
      猜你喜欢
      • 1970-01-01
      • 2011-04-22
      • 1970-01-01
      • 2015-08-24
      • 2014-04-25
      • 2013-08-25
      • 2011-07-31
      • 2013-04-04
      • 1970-01-01
      相关资源
      最近更新 更多