Skip to content

Commit

Permalink
(chocolatey#146) Check state after install / upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
pauby committed Jul 16, 2021
1 parent da95770 commit 4cc760e
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 4cc760e

Please sign in to comment.