Skip to content

Commit

Permalink
resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreenegit committed Feb 27, 2019
2 parents 7e56a1c + c3928eb commit 3030f47
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 53 deletions.
1 change: 1 addition & 0 deletions DSCResource.Tests
Submodule DSCResource.Tests added at e7b358
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# DSC resource to initialize and configure WSUS Server.

# Classifications ID reference...
#
#
# Applications = 5C9376AB-8CE6-464A-B136-22113DD69801
# Connectors = 434DE588-ED14-48F5-8EED-A15E09A991F6
# Critical Updates = E6CF1350-C01B-414D-A61F-263D14D133B4
Expand Down Expand Up @@ -63,16 +63,16 @@ function Get-TargetResource
$WsusConfiguration = $WsusServer.GetConfiguration()
Write-Verbose -Message 'Getting WSUSServer subscription'
$WsusSubscription = $WsusServer.GetSubscription()

Write-Verbose -Message 'Getting WSUSServer SQL Server'
$SQLServer = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Update Services\Server\Setup' `
-Name 'SQLServerName').SQLServerName
-Name 'SQLServerName').SQLServerName
Write-Verbose -Message "WSUSServer SQL Server is $SQLServer"
Write-Verbose -Message 'Getting WSUSServer content directory'
$ContentDir = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Update Services\Server\Setup' `
-Name 'ContentDir').ContentDir
-Name 'ContentDir').ContentDir
Write-Verbose -Message "WSUSServer content directory is $ContentDir"

Write-Verbose -Message 'Getting WSUSServer update improvement program'
$UpdateImprovementProgram = $WsusConfiguration.MURollupOptin
Write-Verbose -Message "WSUSServer content update improvement program is $UpdateImprovementProgram"
Expand All @@ -94,7 +94,7 @@ function Get-TargetResource
$UpstreamServerSSL = $null
$UpstreamServerReplica = $null
}

if($WsusConfiguration.UseProxy)
{
Write-Verbose -Message 'Getting WSUSServer proxy server'
Expand Down Expand Up @@ -128,9 +128,9 @@ function Get-TargetResource
Write-Verbose -Message "WSUSServer languages are $Languages"

Write-Verbose -Message 'Getting WSUSServer classifications'
if ($Classifications = @($WsusSubscription.GetUpdateClassifications().ID.Guid))
{
if($null -eq (Compare-Object -ReferenceObject ($Classifications | Sort-Object -Unique) -DifferenceObject (($WsusServer.GetUpdateClassifications().ID.Guid) | Sort-Object -Unique) -SyncWindow 0))
if ($Classifications = @($WsusSubscription.GetUpdateClassifications().ID.Guid)) {
if($null -eq (Compare-Object -ReferenceObject ($Classifications | Sort-Object -Unique) -DifferenceObject `
(($WsusServer.GetUpdateClassifications().ID.Guid) | Sort-Object -Unique) -SyncWindow 0))
{
$Classifications = @("*")
}
Expand All @@ -140,9 +140,9 @@ function Get-TargetResource
}
Write-Verbose -Message "WSUSServer classifications are $Classifications"
Write-Verbose -Message 'Getting WSUSServer products'
if ($Products = @($WsusSubscription.GetUpdateCategories().Title))
{
if($null -eq (Compare-Object -ReferenceObject ($Products | Sort-Object -Unique) -DifferenceObject (($WsusServer.GetUpdateCategories().Title) | Sort-Object -Unique) -SyncWindow 0))
if ($Products = @($WsusSubscription.GetUpdateCategories().Title)) {
if($null -eq (Compare-Object -ReferenceObject ($Products | Sort-Object -Unique) -DifferenceObject `
(($WsusServer.GetUpdateCategories().Title) | Sort-Object -Unique) -SyncWindow 0))
{
$Products = @("*")
}
Expand All @@ -158,6 +158,8 @@ function Get-TargetResource
Write-Verbose -Message "WSUSServer synchronize automatically time of day is $SynchronizeAutomaticallyTimeOfDay"
$SynchronizationsPerDay = $WsusSubscription.NumberOfSynchronizationsPerDay
Write-Verbose -Message "WSUSServer number of synchronizations per day is $SynchronizationsPerDay"
$ClientTargetingMode = $WsusConfiguration.TargetingMode
Write-Verbose -Message "WSUSServer client targeting mode is $ClientTargetingMode"
}

$returnValue = @{
Expand All @@ -179,6 +181,7 @@ function Get-TargetResource
SynchronizeAutomatically = $SynchronizeAutomatically
SynchronizeAutomaticallyTimeOfDay = $SynchronizeAutomaticallyTimeOfDay
SynchronizationsPerDay = $SynchronizationsPerDay
ClientTargetingMode = $ClientTargetingMode
}

$returnValue
Expand Down Expand Up @@ -229,6 +232,9 @@ function Get-TargetResource
Number of automatic synchronizations per day
.PARAMETER Synchronize
Run a synchronization immediately when running Set
.PARAMETER ClientTargetingMode
An enumerated value that describes if how the Target Groups are populated.
Accepts 'Client'(default) or 'Server'.
#>
function Set-TargetResource
{
Expand Down Expand Up @@ -314,7 +320,11 @@ function Set-TargetResource

[Parameter()]
[System.Boolean]
$Synchronize
$Synchronize,

[ValidateSet("Client", "Server")]
[System.String]
$ClientTargetingMode
)

# Is WSUS configured?
Expand Down Expand Up @@ -356,11 +366,11 @@ function Set-TargetResource
Write-Verbose -Message [string]$Process
Wait-Win32ProcessEnd -Path $Path -Arguments $Arguments
}
else
else
{
$Process = Start-Win32Process -Path $Path -Arguments $Arguments
Write-Verbose -Message [string]$Process
Wait-Win32ProcessEnd -Path $Path -Arguments $Arguments
Wait-Win32ProcessEnd -Path $Path -Arguments $Arguments
}
}

Expand Down Expand Up @@ -450,6 +460,13 @@ function Set-TargetResource
$WsusConfiguration.SetEnabledUpdateLanguages($Languages)
}

#ClientTargetingMode
if($PSBoundParameters.ContainsKey("Client Targeting Mode"))
{
Write-Verbose -Message "Setting WSUS client targeting mode"
$WsusConfiguration.TargetingMode = $ClientTargetingMode
}

# Save configuration before initial sync
SaveWsusConfiguration

Expand Down Expand Up @@ -508,11 +525,11 @@ function Set-TargetResource
Write-Verbose -Message [string]$Process
Wait-Win32ProcessEnd -Path $Path -Arguments $Arguments
}
else
else
{
$Process = Start-Win32Process -Path $Path -Arguments $Arguments
Write-Verbose -Message [string]$Process
Wait-Win32ProcessEnd -Path $Path -Arguments $Arguments
Wait-Win32ProcessEnd -Path $Path -Arguments $Arguments
}

$WsusConfiguration.OobeInitialized = $true
Expand Down Expand Up @@ -563,10 +580,11 @@ function Set-TargetResource
{
foreach($Classification in $Classifications)
{
if($WsusClassification = $AllWsusClassifications | Where-Object {$_.ID.Guid -eq $Classification})
if($WsusClassification = $AllWsusClassifications | `
Where-Object {$_.ID.Guid -eq $Classification})
{
$null = $ClassificationCollection.Add($WsusServer.GetUpdateClassification(`
$WsusClassification.Id))
$WsusClassification.Id))
}
else
{
Expand All @@ -590,7 +608,7 @@ function Set-TargetResource
if($Synchronize)
{
Write-Verbose -Message "Synchronizing WSUS"

$WsusServer.GetSubscription().StartSynchronization()
while($WsusServer.GetSubscription().GetSynchronizationStatus() -eq 'Running')
{
Expand Down Expand Up @@ -659,6 +677,9 @@ function Set-TargetResource
Number of automatic synchronizations per day
.PARAMETER Synchronize
Run a synchronization immediately when running Set
.PARAMETER ClientTargetingMode
An enumerated value that describes if how the Target Groups are populated.
Accepts 'Client'(default) or 'Server'.
#>
function Test-TargetResource
{
Expand Down Expand Up @@ -745,7 +766,11 @@ function Test-TargetResource

[Parameter()]
[System.Boolean]
$Synchronize
$Synchronize,

[ValidateSet("Client", "Server")]
[System.String]
$ClientTargetingMode
)

$result = $true
Expand Down Expand Up @@ -838,20 +863,23 @@ function Test-TargetResource
}
}
else {
if($null -ne (Compare-Object -ReferenceObject ($Wsus.Languages | Sort-Object -Unique) -DifferenceObject ($Languages | Sort-Object -Unique) -SyncWindow 0))
if((Compare-Object -ReferenceObject ($Wsus.Languages | Sort-Object -Unique) `
-DifferenceObject ($Languages | Sort-Object -Unique) -SyncWindow 0) -ne $null)
{
Write-Verbose -Message "Languages test failed"
$result = $false
}
}
}
# Test Products
if($null -ne (Compare-Object -ReferenceObject ($Wsus.Products | Sort-Object -Unique) -DifferenceObject ($Products | Sort-Object -Unique) -SyncWindow 0))
if((Compare-Object -ReferenceObject ($Wsus.Products | Sort-Object -Unique) `
-DifferenceObject ($Products | Sort-Object -Unique) -SyncWindow 0) -ne $null)
{
Write-Verbose -Message "Products test failed"
$result = $false
}
# Test Classifications
if($null -ne (Compare-Object -ReferenceObject ($Wsus.Classifications | Sort-Object -Unique) -DifferenceObject ($Classifications | Sort-Object -Unique) -SyncWindow 0))
if((Compare-Object -ReferenceObject ($Wsus.Classifications | Sort-Object -Unique) `
-DifferenceObject ($Classifications | Sort-Object -Unique) -SyncWindow 0) -ne $null)
{
Write-Verbose -Message "Classifications test failed"
$result = $false
Expand All @@ -873,6 +901,19 @@ function Test-TargetResource
$result = $false
}
}

# Test Client Targeting Mode
if($ClientTargetingMode)
{
if($PSBoundParameters.ContainsKey('ClientTargetingMode'))
{
if($Wsus.ClientTargetingMode -ne $ClientTargetingMode)
{
Write-Verbose -Message "ClientTargetingMode test failed"
$result = $false
}
}
}
}

$result
Expand All @@ -897,7 +938,7 @@ function SaveWsusConfiguration
Start-Sleep -Seconds 1
}
}
until($WsusConfigurationReady)
until($WsusConfigurationReady)
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ class MSFT_UpdateServicesServer : OMI_BaseResource
[Write, Description("First synchronization.")] String SynchronizeAutomaticallyTimeOfDay;
[Write, Description("Synchronizations per day.")] UInt16 SynchronizationsPerDay;
[Write, Description("Begin initial synchronization.")] Boolean Synchronize;
[write, Description("An enumerated value that describes if how the Target Groups are populated.\nClient {default} \nServer \n"), ValueMap{"Client","Server"}, Values{"Client","Server"}] String ClientTargetingMode;
};
1 change: 1 addition & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ This module requires a minimum version of PowerShell v5.0.
- **SynchronizationsPerDay**: Synchronizations per day.
- **Synchronize**: Begin initial synchronization.
- **RunRuleNow**: Run Approval Rule on existing content.
- **ClientTargetingMode**: An enumerated value that describes if how the Target Groups are populated.

## Renaming Requirements

Expand Down
Loading

0 comments on commit 3030f47

Please sign in to comment.