From 7cc690d99127c8e2a388050c28efd720ed3132cc Mon Sep 17 00:00:00 2001 From: Russell Anderson Date: Mon, 2 Mar 2020 19:49:13 -0700 Subject: [PATCH] #1179 --- CHANGELOG.md | 6 ++++++ .../MSFT_SPFarmSolution/MSFT_SPFarmSolution.psm1 | 10 ++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3a0b7450..25c2cc11b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- SPFarmSolution + - Corrected bug running Solution Job wait for an Absent solution. + - Corrected bug trying to remove an already Absent solution. + ## [3.8.0] - 2020-02-27 ### Added diff --git a/SharePointDsc/DSCResources/MSFT_SPFarmSolution/MSFT_SPFarmSolution.psm1 b/SharePointDsc/DSCResources/MSFT_SPFarmSolution/MSFT_SPFarmSolution.psm1 index 5a7ef54ba..412841fdd 100644 --- a/SharePointDsc/DSCResources/MSFT_SPFarmSolution/MSFT_SPFarmSolution.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPFarmSolution/MSFT_SPFarmSolution.psm1 @@ -345,10 +345,16 @@ function Set-TargetResource } } - Wait-SPDscSolutionJob -SolutionName $Name -InstallAccount $InstallAccount + if ($Ensure -eq "Present") + { + Write-Verbose -Message "Waiting for farm solution '$Name' job" + Wait-SPDscSolutionJob -SolutionName $Name -InstallAccount $InstallAccount + } - if ($Ensure -eq "Absent") + if ($Ensure -eq "Absent" -and $CurrentValues.Ensure -ne "Absent") { + Write-Verbose -Message "Removing farm solution '$Name'" + $result = Invoke-SPDscCommand -Credential $InstallAccount ` -Arguments $PSBoundParameters ` -ScriptBlock {