Skip to content

Commit

Permalink
Changes for #42
Browse files Browse the repository at this point in the history
  • Loading branch information
raandree committed Dec 2, 2018
1 parent c65944a commit 8558701
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions AutomatedLab.Common/Common/Public/Install-SoftwarePackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,34 @@ function Install-SoftwarePackage

[system.management.automation.pscredential]$Credential
)

Add-Type -TypeDefinition @'
namespace AutomatedLab.Common
{
using System;
public class Win32Exception : System.ComponentModel.Win32Exception
{
public new int ErrorCode { get; set; }
public Win32Exception(int error) : base(error)
{
ErrorCode = error;
}
public Win32Exception(string message) : base(message)
{ }
public Win32Exception(int error, string message) : base(error, message)
{
ErrorCode = error;
}
public Win32Exception(string message , Exception innerException) : base(message, innerException)
{ }
}
}
'@

#region New-InstallProcess
function New-InstallProcess
Expand Down Expand Up @@ -205,11 +233,11 @@ function Install-SoftwarePackage

Write-Verbose "Exit code of installation process is '$($result.Process.ExitCode)'"
if ($result.Process.ExitCode -ne 0 `
-and $result.Process.ExitCode -ne 3010 `
-and $result.Process.ExitCode -ne $null `
-and $result.Process.ExitCode -ne 3010 `
-and $result.Process.ExitCode -ne $null `
-and $ExpectedReturnCodes -notcontains $result.Process.ExitCode )
{
throw (New-Object System.ComponentModel.Win32Exception($result.Process.ExitCode))
throw (New-Object AutomatedLab.Common.Win32Exception($result.Process.ExitCode))
}
else
{
Expand Down

0 comments on commit 8558701

Please sign in to comment.