Skip to content

Commit

Permalink
Merge pull request #1 from pauby/fix/failed-install-upgrade
Browse files Browse the repository at this point in the history
(chocolatey#146) Check state after install / upgrade
  • Loading branch information
MattJeanes committed May 10, 2022
2 parents a724722 + 4cc760e commit 559341c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,20 @@ function Set-TargetResource
InstallPackage -pName $Name -pParams $Params -pVersion $versionToInstall -pSource $Source -cParams $chocoParams
}
}

# check state of package
$isInstalled = IsPackageInstalled -pName $Name

if ($Ensure -eq 'Absent') {
if ($isInstalled -eq $true) {
throw "Failed to uninstall Chocolatey package '$Name'."
}
}
else {
if ($isInstalled -eq $false) {
throw "Failed to install Chocolatey package '$Name'."
}
}
}

function Test-TargetResource
Expand Down

0 comments on commit 559341c

Please sign in to comment.