diff --git a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 index 539845a..26da3dc 100644 --- a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 +++ b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 @@ -504,7 +504,12 @@ function Get-ChocoInstalledPackage { $ChocoInstallList = Join-Path -Path $ChocoInstallLP -ChildPath 'ChocoInstalled.xml' if ($Purge.IsPresent) { - Remove-Item $ChocoInstallList -Force + if (Test-Path -Path $ChocoInstallList) { + Write-Verbose "Purging old ChocoInstalled.xml file at $ChocoInstallList" + Remove-Item $ChocoInstallList -Force + } else { + Write-Verbose "Did not locate ChocoInstalled.xml file to remove at $ChocoInstallList, taking no action" + } $res = $true } else { $PackageCacheSec = (Get-Date).AddSeconds('-60')