Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UpdateServicesServer] Add IGNORE option to UpstreamServerName #56

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Updated inital offline package sync WSUS.cab.
- Added IGNORE option for UpstreamServerName to prevent it being changed when SCCM is managing the upstream source

## [1.2.0] - 2020-05-18

Expand Down
2 changes: 1 addition & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Windows Server 2008 R2 SP1, Windows Server 2012 and Windows Server 2012 R2.
* **SQLServer**: SQL Server for the WSUS database, omit for Windows Internal Database.
* **ContentDir**: Folder for WSUS update files.
* **UpdateImprovementProgram**: Join the Microsoft Update Improvement Program.
* **UpstreamServerName**: Upstream WSUS server, omit for Microsoft Update.
* **UpstreamServerName**: Upstream WSUS server, omit for Microsoft Update. Set to 'IGNORE' to prevent changes being made, for example in a SCCM environment
* **UpstreamServerPort**: Port of upstream WSUS server.
* **UpstreamServerSSL**: Use SSL with upstream WSUS server.
* **UpstreamServerReplica**: Replica of upstream WSUS server.
Expand Down
31 changes: 30 additions & 1 deletion Tests/Unit/MSFT_UpdateServicesServer.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,36 @@ try
}
}

}
Context "upstream server difference is ignored" {

$DSCTestValues.Remove('UpstreamServerName')
$DSCTestValues.Add('UpstreamServerName', 'IGNORE')

Mock -CommandName Get-TargetResource -MockWith {
$GetValues = $DSCTestValues
$GetValues.Remove('UpstreamServerName')
$GetValues.Add('UpstreamServerName', 'SomeOtherServer')
$GetValues
} -Verifiable

$script:result = $null

It "calling test with change to UpstreamServerName should not throw" {
{ $script:result = Test-TargetResource @DSCTestValues -verbose } | Should not throw
}

It "result should be true, even when UpstreamServerName is different" {
$script:result | Should be $true
}

It 'mocks were called' {
Assert-VerifiableMock
}

$DSCTestValues.Remove('UpstreamServerName')
$DSCTestValues.Add('UpstreamServerName', 'UpstreamServer')
}
}
#endregion

#region Function Set-TargetResource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,8 @@ function Test-TargetResource
}

# Test Upstream Server
if ($Wsus.UpstreamServerName -ne $UpstreamServerName)

if ($Wsus.UpstreamServerName -ne $UpstreamServerName -and $UpstreamServerName -ne "IGNORE")
{
Write-Verbose -Message $script:localizedData.UpstreamNameTestFailed
$result = $false
Expand Down