Created
January 22, 2019 21:57
-
-
Save Robert-LTH/e6e87b88ffe210eb4ccb409dd52ef41d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[string]$ExitCode | |
) | |
# http://www.msierrors.com/drivers/dpinst-exit-codes-explained/ | |
$DPInstInfo = New-Object psobject @{ | |
PackageInstallationFailure = $false | |
RebootRequired = $false | |
<# | |
OperationStatus = 0 | |
DriversInstalled = 0 | |
DriversCopiedToDriverStore = 0 | |
DriversNotInstalled = 0 | |
#> | |
} | |
# Parse the number as a HexNumber and store it as UInt32 because the highest bit indicates a package install failure. | |
$ExitCodeUInt32 = [UInt32]::Parse($ExitCode,([System.Globalization.NumberStyles]::HexNumber)) | |
# The highest 8 bytes tells us how it went and if we need to reboot afterwards | |
$DPInstInfo.OperationStatus = (($ExitCodeUInt32 -band 0xFF000000) -shr 24) | |
# Number of driver packages that could not be installed - This should always be zero | |
$DPInstInfo.DriversNotInstalled = (($ExitCodeUInt32 -band 0x00FF0000) -shr 16) | |
# Number of driver packages that have been copied to the driver store but haven’t been installed on a device | |
$DPInstInfo.DriversCopiedToDriverStore = (($ExitCodeUInt32 -band 0x0000FF00) -shr 8) | |
# Number of driver packages that have been installed on a device | |
$DPInstInfo.DriversInstalled = (($ExitCodeUInt32 -band 0x000000FF)) | |
Switch ($DPInstInfo.OperationStatus) { | |
0x80 { | |
$DPInstInfo.PackageInstallationFailure = $true | |
} | |
0x40 { | |
$DPInstInfo.RebootRequired = $true | |
} | |
} | |
$DPInstInfo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment