Where can I find a list of exit codes and their meanings for the PowerShell ServerManager cmdlet?

1.9k views Asked by At

I'm using the PowerShell ServerManager cmdlet and haven't been able to find a comprehensive list of exit codes for the installation commands.

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

What values can I expect ExitCode to contain?

2

There are 2 answers

1
latkin On BEST ANSWER

I have never used this cmdlet, but based on @vmrob's initial answer, it appears that ExitCode is in instance of the Microsoft.Windows.ServerManager.Commands.FeatureOperationExitCode enum type.

You should be able to get a list of possible values like this:

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

It's possible that the current version of the PowerShell cmdlets act as a wrapper around the deprecated servermanagercmd.exe. If this is the case, then the exit codes listed here should be applicable:

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

The exit codes that I've encountered so far match:

With a feature that is already installed

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

When a feature fails to install due to a needed restart

This can happen after Windows Update runs but before the computer is restarted.

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

On success

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