From e9b8836975a9ea509ef416f0af9932717ed4c8a2 Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Tue, 27 Oct 2020 16:32:24 +0100 Subject: [PATCH] Fixes issue #1195 --- CHANGELOG.md | 3 +++ .../MSFT_SPConfigWizard.psm1 | 19 +++++++++++++++++++ .../SharePointDsc.SPConfigWizard.Tests.ps1 | 8 ++++++++ 3 files changed, 30 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b078b7821..ce0eac573 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- SPConfigWizard + - Fixes issue where a CU installation wasn't registered properly in the + config database. Added logic to run the Product Version timer job - SPSearchTopology - Fixes issue where applying a topology failed when the search service instance was disabled instead of offline diff --git a/SharePointDsc/DSCResources/MSFT_SPConfigWizard/MSFT_SPConfigWizard.psm1 b/SharePointDsc/DSCResources/MSFT_SPConfigWizard/MSFT_SPConfigWizard.psm1 index fab968773..b3ee71c4d 100644 --- a/SharePointDsc/DSCResources/MSFT_SPConfigWizard/MSFT_SPConfigWizard.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPConfigWizard/MSFT_SPConfigWizard.psm1 @@ -254,6 +254,25 @@ function Set-TargetResource -ScriptBlock { $psconfigExe = $args[0] + Write-Verbose -Message "Starting 'Product Version Job' timer job" + $pvTimerJob = Get-SPTimerJob -Identity 'job-admin-product-version' + $lastRunTime = $pvTimerJob.LastRunTime + + Start-SPTimerJob -Identity $pvTimerJob + + $jobRunning = $true + $maxCount = 30 + $count = 0 + while ($jobRunning -and $count -le $maxCount) + { + Start-Sleep -Seconds 10 + + $pvTimerJob = Get-SPTimerJob -Identity 'job-admin-product-version' + $jobRunning = $lastRunTime -eq $pvTimerJob.LastRunTime + + $count++ + } + $stdOutTempFile = "$env:TEMP\$((New-Guid).Guid)" $psconfig = Start-Process -FilePath $psconfigExe ` -ArgumentList "-cmd upgrade -inplace b2b -wait -cmd applicationcontent -install -cmd installfeatures -cmd secureresources -cmd services -install" ` diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPConfigWizard.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPConfigWizard.Tests.ps1 index 8b6949df2..f1df5b565 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPConfigWizard.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPConfigWizard.Tests.ps1 @@ -52,6 +52,14 @@ try Invoke-Command -ScriptBlock $Global:SPDscHelper.InitializeScript -NoNewScope # Mocks for all contexts + Mock -CommandName Start-Sleep -MockWith { } + Mock -CommandName Start-SPTimerJob -MockWith { } + Mock -CommandName Get-SPTimerJob -MockWith { + return @{ + LastRunTime = Get-Date + } + } + Mock -CommandName Remove-Item -MockWith { } Mock -CommandName Get-Content -MockWith { return "log info" } Mock -CommandName Get-SPDscServerPatchStatus -MockWith { return "UpgradeRequired" }