Skip to content

Instantly share code, notes, and snippets.

@PrateekKumarSingh
Last active April 13, 2018 11:19
Show Gist options
  • Save PrateekKumarSingh/3386fb492460030c809bbe468b419839 to your computer and use it in GitHub Desktop.
Save PrateekKumarSingh/3386fb492460030c809bbe468b419839 to your computer and use it in GitHub Desktop.
# Running MSI installation
$MSIFile = @('C:\users\prateesi\download\zoomit.msi')
$MSIEXECPath = "$env:SystemRoot\system32\msiexec.exe"
(Start-Process $MSIEXECPath -ArgumentList "/i `"$MSIFile`" /qn" -Wait -PassThru).exitcode
# Running WUSA/ .EXE installation
$path = "C:\Users\prateesi\Downloads\Win7AndW2K8R2-KB3134760-x64.msu"
$ExitCode = (Start-Process 'wusa.exe' -ArgumentList "`"$path`" /quiet" -wait -PassThru).exitcode
Function Get-ExitCodeInformation($ExitCode)
{
$IE = New-Object -ComObject InternetExplorer.Application
$IE.Navigate("https://msdn.microsoft.com/en-us/library/windows/desktop/aa376931(v=vs.85).aspx")
Start-Sleep -s 2
$IEDom = $IE.Document
$Table = (($IEDom).getElementsByTagName("Table"))[0]
$TableBody = $Table.childNodes| ?{$_.tagName -eq "tbody"}
$TableRows = $TableBody.childNodes | ?{ $_.tagName -eq "tr" }
$MSIExitCodes = Foreach($tr in $TableRows)
{
$ErrorString, $ErrorCode, $Desc = ($tr.childNodes|?{$_.tagname -eq 'td'}).innerhtml
If($ErrorString)
{
''| Select @{n='ErrorString';e={$ErrorString.Trim()}}, @{n='ErrorCode';e={$ErrorCode.Trim()}}, @{n='Description';e={$Desc.Trim()}}
}
}
$MSIExitCodes | ?{$_.errorcode -eq $ExitCode}
$IE.quit()
}
Get-ExitCodeInformation $ExitCode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment