dsccommunity / updateservicesdsc Goto Github PK
View Code? Open in Web Editor NEWThis module contains community maintained DSC resources for deployment and configuration of Windows Server Update Services.
License: MIT License
This module contains community maintained DSC resources for deployment and configuration of Windows Server Update Services.
License: MIT License
I have a specific array of Windows Products that I have entered for the "Products" portion in the UpdateServicesServer resource. When I attempt to load the DSC configuration, I get the following error during test/set:
Products test failed.
Cannot validate argument on parameter 'ErrorRecord'. The argument is null. Provide a valid value for the argument, and then try running the command again. At line:1 char:21 + $params = $args[0]; Set-TargetResource @params -Verbose + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
See above
Uncertain at this time. I switched to a single product for the configuration resource & it completed successfully. I believe it has something to do with my product list.
See the code here: https://github.com/microsoft/WindowsServerUpdateServicesConfig/blob/master/WindowsServerUpdateServicesConfig.ps1#L70-L73
N/A
Should be running PS 5.1
'UpdateServicesDsc' Version 1.2.1
Configured WSUS using DSC. SCCM then used the configured instance, and set the Upstream Server. Expected that DSC would ignore this as the option is not specified in the declared configuration. Found that DSC performed a reconfigure of WSUS back to Microsoft Update. SCCM then reconfigured again, and we went round in a circle.
[[UpdateServicesServer]SccmCasHa-WsusConfig::[SccmCasHa]xSccmCasHa] Upstream Server Name test failed
Only return $false from Test Resource if the Upstream Server Name does not match the current server name, and the UpstreamServerName option has been specified in the declared configuration.
UpdateServicesServer SccmCasHa-WsusConfig {
Ensure = "Present"
ContentDir = $WsusContentDir
SqlServer = $WsusSqlInstance
SetupCredential = $WsusSqlInstanceAdmin
UpdateImprovementProgram = $false
DependsOn = @(
"[WindowsFeature]SccmCasHa-WsusServicesSql",
"[WindowsFeature]SccmCasHa-WsusServices"
)
}
OsName : Microsoft Windows Server 2016 Standard
OsOperatingSystemSKU : StandardServerEdition
OsArchitecture : 64-bit
WindowsBuildLabEx : 14393.3630.amd64fre.rs1_release.200407-1730
OsLanguage : en-US
OsMuiLanguages : {en-US}
Name Value
PSVersion 5.1.14393.3471
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.3471
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
1.2.1
The UpdateServicesServer
resource fails to configure Products when there are multiple entries returned for a given name (e.g. "Windows Admin Center" is a Product Family as well as Product):
$WsusServer = Get-WsusServer
$AllWsusProducts = $WsusServer.GetUpdateCategories()
$ProductCollection = New-Object Microsoft.UpdateServices.Administration.UpdateCategoryCollection
$Product = 'Windows Admin Center'
$WsusProduct = $AllWsusProducts | Where-Object -FilterScript { $_.Title -eq $Product }
# WsusProduct now contains 2 members:
$WsusProduct
Type : ProductFamily
ProhibitsSubcategories : False
ProhibitsUpdates : True
UpdateSource : MicrosoftUpdate
UpdateServer : Microsoft.UpdateServices.Internal.BaseApi.UpdateServer
Id : a871ee2d-7499-6719-3781-8c63a1642990
Title : Windows Admin Center
Description : Product Family for Windows Admin Center
ReleaseNotes :
DefaultPropertiesLanguage :
DisplayOrder : 2147483647
ArrivalDate : 2/12/2021 4:37:45 PM
Type : Product
ProhibitsSubcategories : True
ProhibitsUpdates : False
UpdateSource : MicrosoftUpdate
UpdateServer : Microsoft.UpdateServices.Internal.BaseApi.UpdateServer
Id : b1b8f641-1ff2-4ae6-b247-4fe7503787be
Title : Windows Admin Center
Description : Windows Admin Center
ReleaseNotes :
DefaultPropertiesLanguage :
DisplayOrder : 2147483647
ArrivalDate : 2/12/2021 4:37:45 PM
This causes the following code to fail:
$null = $ProductCollection.Add($WsusServer.GetUpdateCategory($WsusProduct.Id))
Cannot find an overload for "GetUpdateCategory" and the argument count: "1".
At line:1 char:1
+ $null = $ProductCollection.Add($WsusServer.GetUpdateCategory($WsusPro ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Mi
crosoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer SRV1 with user sid S-1-5-21-2574420874-2490326428-1586090461-500.
VERBOSE: [SRV1]: LCM: [ Start Set ]
VERBOSE: [SRV1]: LCM: [ Start Resource ] [[UpdateServicesServer]WSUS]
VERBOSE: [SRV1]: LCM: [ Start Test ] [[UpdateServicesServer]WSUS]
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WSUS server.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUS server is Present.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WSUS server configuration.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WUSS server subscription.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WSUS SQL server.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUS Server SQL Server is MICROSOFT##WID.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WSUSServer content directory.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUS Server content directory is E:\.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WSUSServer update improvement program.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUS Server content update improvement program is False.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WSUS Server languages.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUS Server languages are System.Collections.Specialized.StringCollection.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WSUS Server Classifications.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUS Server Classifications are e6cf1350-c01b-414d-a61f-263d14d133b4.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WSUS Server products.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUS Server products are Windows Server 2016.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WSUSServer synchronization settings.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUS Server synchronize automatically is False.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUS Server synchronize automatically time of day is 06:33:59.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUSServer number of synchronizations per day is 1.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUSServer client targeting mode is Server.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Products test failed.
VERBOSE: [SRV1]: LCM: [ End Test ] [[UpdateServicesServer]WSUS] in 1.4690 seconds.
VERBOSE: [SRV1]: LCM: [ Start Set ] [[UpdateServicesServer]WSUS]
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Configuring Wsus.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Check for previous configuration change.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Configuring WSUS Update Improvement Program.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Configuring WSUS for Microsoft Update.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Configuring WSUS no proxy server.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Setting WSUS languages.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Setting WSUS products.
Cannot find an overload for "GetUpdateCategory" and the argument count: "1".
+ CategoryInfo : NotSpecified: (:) [], CimException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest
+ PSComputerName : localhost
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Setting WSUS classifications.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Setting WSUS synchronization schedule.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WSUS server.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUS server is Present.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WSUS server configuration.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WUSS server subscription.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WSUS SQL server.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUS Server SQL Server is MICROSOFT##WID.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WSUSServer content directory.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUS Server content directory is E:\.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WSUSServer update improvement program.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUS Server content update improvement program is False.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WSUS Server languages.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUS Server languages are System.Collections.Specialized.StringCollection.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WSUS Server Classifications.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUS Server Classifications are e6cf1350-c01b-414d-a61f-263d14d133b4.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WSUS Server products.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUS Server products are *.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WSUSServer synchronization settings.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUS Server synchronize automatically is False.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUS Server synchronize automatically time of day is 06:33:59.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUSServer number of synchronizations per day is 1.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUSServer client targeting mode is Server.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Products test failed.
Cannot validate argument on parameter 'ErrorRecord'. The argument is null. Provide a valid value for the argument, and then try running the command again.
+ CategoryInfo : InvalidData: (:) [], CimException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,New-InvalidResultException
+ PSComputerName : localhost
VERBOSE: [SRV1]: LCM: [ End Set ] [[UpdateServicesServer]WSUS] in 0.6250 seconds.
The PowerShell DSC resource '[UpdateServicesServer]WSUS' with SourceInfo '::7::9::UpdateServicesServer' threw one or more non-terminating errors while running the Set-TargetResource
functionality. These errors are logged to the ETW channel called Microsoft-Windows-DSC/Operational. Refer to this channel for more details.
+ CategoryInfo : InvalidOperation: (:) [], CimException
+ FullyQualifiedErrorId : NonTerminatingErrorFromProvider
+ PSComputerName : localhost
VERBOSE: [SRV1]: LCM: [ End Set ]
The SendConfigurationApply function did not succeed.
+ CategoryInfo : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
+ FullyQualifiedErrorId : MI RESULT 1
+ PSComputerName : localhost
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 2.749 seconds
Adjust the code to process multiple entries in $WsusProduct
separately:
if ($WsusProduct = $AllWsusProducts | Where-Object -FilterScript { $_.Title -eq $Product })
{
$WsusProduct | Foreach-Object -Process {
$null = $ProductCollection.Add($_)
}
}
Similar change would likely be needed as part of solution to #13
Configuration WSUSProduct {
Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
Import-DscResource -ModuleName 'UpdateServicesDsc' -ModuleVersion 1.2.1
Node localhost {
UpdateServicesServer WSUS {
Ensure = 'Present'
Languages = 'en'
Products = 'Windows Admin Center'
}
}
}
OsName : Microsoft Windows Server 2019 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture : 64-bit
WindowsVersion : 1809
WindowsBuildLabEx : 17763.1.amd64fre.rs5_release.180914-1434
OsLanguage : en-US
OsMuiLanguages : {en-US}
Name Value
---- -----
PSVersion 5.1.17763.1490
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.1490
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Name Version Path
---- ------- ----
UpdateServicesDsc 1.2.1 C:\Program Files\WindowsPowerShell\Modules\UpdateServicesDsc\1.2.1\UpdateServicesDsc.psd1
Just wondering if this resource is still planned to be merged into the Powershell DSC repo? https://github.com/PowerShell/DscResources
The current interface doesn't allow the Download Properties to be set. It so happens that the defaults work correctly but since these settings are critical to our image build process, they should be strictly defined - any in any case, other users may have different requirements.
These are equivalent to the following Powershell properties:
(Get-WsusServer).GetConfiguration().HostBinariesOnMicrosoftUpdate
(Get-WsusServer).GetConfiguration().DownloadExpressPackages
(Get-WsusServer).GetConfiguration().DownloadUpdateBinariesAsNeeded
There is a bug in definition of scheduled task:
Some of the variables in that block are escaped resulting in:
$true;$CleanupUnneededContentFiles = $true;$CleanupLocalPublishedContentFiles = $true; = Get-WsusServer
if()
{
'WSUS Server found...' | Out-File (Join-Path -Path ([IO.Path]::GetTempPath()) -ChildPath 'WsusCleanup.txt') -Append
= $WsusServer.GetCleanupManager()
if()
{
'WSUS Cleanup Manager found...' | Out-File (Join-Path -Path ([IO.Path]::GetTempPath()) -ChildPath 'WsusCleanup.txt') -Append
= New-Object Microsoft.UpdateServices.Administration.CleanupScope(True,True,True,True,True,True,True)
= .PerformCleanup()
if()
{
| Out-File (Join-Path -Path ([IO.Path]::GetTempPath()) -ChildPath 'WsusCleanup.txt') -Append
}
}
}
Also: having an argument like that makes it hard to maintain. Perhaps generate a script instead and call it with -file
parameter?
As an example i'm trying to update all SQL servers using Update Services
I will need to create a list like this
Microsoft SQL Server 2008 R2 - PowerPivot for Microsoft Excel 2010
Microsoft SQL Server 2012
Microsoft SQL Server 2014
Microsoft SQL Server 2016
Microsoft SQL Server PowerPivot for Excel
SQL Server 2000
SQL Server 2005
SQL Server 2008 R2
SQL Server 2008
SQL Server 2012 Product Updates for Setup
SQL Server 2014-2016 Product Updates for Setup
SQL Server Feature Pack
SQL Server
if($WsusProduct = $AllWsusProducts | Where-Object {$_.Title -eq $Product})
If the above like could be changes to
if($WsusProduct = $AllWsusProducts | Where-Object {$_.Title -like $Product})
it will allow me to do just the following keyword "SQL Server"
The Languages field is unable to handle multiple languages when configuring WSUS.
The code sample at the bottom of this issue causes the following error to be returned:
failed to execute Set-TargetResource functionality with error message: Test-TargetResouce returned false after calling set
Have done some investigation of this with @RandomNoun7 and will submit a PR shortly to address it.
Multiple languages (e.g. "en","ja","fr"
) are being set
correctly, but the subsequent test
fails to validate the setting because of a data mismatch in the comparison which causes the language test to fail if more than one language is set.
The code sample that demonstrates this fault is below:
$script:ErrorActionPreference = 'Stop'
$script:WarningPreference = 'SilentlyContinue'
function new-pscredential{
[CmdletBinding()]
param (
[parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
[string]$user,
[parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
[string]$password
)
$secpasswd = ConvertTo-SecureString $password -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PSCredential ($user, $secpasswd)
return $credentials
}
$response = @{
indesiredstate = $false
rebootrequired = $false
errormessage = ''
}
$invokeParams = @{
Name = 'UpdateServicesServer'
ModuleName = 'UpdateServicesDsc'
Method = 'set'
Property = @{
'ensure' = 'present';
'contentdir' = 'C:\WSUS';
'languages' = @('en', 'fr', 'ja');
'products' = @('Windows 10 LTSB', 'Windows 10', 'Windows 7', 'Windows 8.1', 'Windows 8', 'Windows Server 2008 R2', 'Windows Server 2008', 'Windows Server 2012 R2', 'Windows Server 2012', 'Windows Server 2016', 'Windows Server 2019');
'classifications' = @('E6CF1350-C01B-414D-A61F-263D14D133B4', 'E0789628-CE08-4437-BE74-2495B842F43B', '0FA1201D-4330-4FA8-8AE9-B877473B6441', '68C5B0A3-D1A6-4553-AE49-01D3A7827828', '28BC880E-0592-4CBF-8F95-C79B17911D5F');
'synchronizeautomatically' = $true;
'synchronizeautomaticallytimeofday' = '15:30:00'
}
}
try{
$result = Invoke-DscResource @invokeParams
}catch{
$response.errormessage = $_.Exception.Message
return ($response | ConvertTo-Json -Compress)
}
# keep the switch for when Test passes back changed properties
switch($invokeParams.Method){
'Test'{
$response.indesiredstate = $result.InDesiredState
return ($response | ConvertTo-Json -Compress)
}
'Set'{
$response.indesiredstate = $true
$response.rebootrequired = $result.RebootRequired
return ($response | ConvertTo-Json -Compress)
}
}
I assume on Read.me under xWSUSApprovalRule
the "Ensure: An enumerated value that describes if WSUS is configured."
is just a small error in description as its probably "..describes if the ApprovalRule is available". ?
Would it be possible to make the task name for the Scheduled WSUS cleanup a parameter instead of a hardcoded value of 'WSUS Cleanup'? This way, the cleanup job can be broken out into multiple tasks, if desired.
(I personally structure my WSUS Cleanup into three jobs: Decline, Delete DB, and Delete Files. It minimizes the timeouts that way)
A resource "UpdateServicesClient" to allow client configuration using DSC instead of GPO. @robwi
Some Wsus products have non ASCII characters in their Title. In particular "Windows Server Manager โ Windows Server Update Services (WSUS) Dynamic Installer" dash (" - ") is not in ASCII format therefore comparison is failing subsequently test and set is failing.
Suggested solution to strip all none alphanumerical characters using this method: ToCharArray().Where{ $_ -imatch "[a-z0-9]" } -join ''
i.e. like this:
foreach ($Product in $Products) {
# Due to none ASCII characters used in Product titles in particular "Windows Server Manager โ Windows Server Update Services (WSUS) Dynamic Installer" dash (" - ") is not in ASCII format
# had to strip all none alphanumerical characters to compare the titles. to do so used this method: ToCharArray().Where{ $_ -imatch "[a-z0-9]" } -join ''
if ($WsusProduct = $AllWsusProducts | Where-Object { ($_.Title.ToCharArray().Where{ $_ -imatch "[a-z0-9]" } -join '') -eq ($Product.ToCharArray().Where{ $_ -imatch "[a-z0-9]" } -join '') }) {
Write-Verbose "Setting WSUS Product: $($Product)"
$null = $ProductCollection.Add($WsusServer.GetUpdateCategory($WsusProduct.Id))
}
}
products = @(
'ASP.NET Web and Data Frameworks'
'ASP.NET Web Frameworks'
'Azure File Sync agent updates for Windows Server 2016'
'Windows Server 2016 and Later Servicing Drivers'
'Windows Server 2016'
'Windows Server Manager - Windows Server Update Services (WSUS) Dynamic Installer'
)
master branch
version: 1.1.0.0
The current version of UpdateServicesDsc
in the Powershell Gallery is 1.0.75.0
dated 31/Mar/2018
Is there a plan to update the gallery ?
Thanks - John
The Email settings are missing:
example:
EmailNotifySmtpServer [string]
EmailNotifySmtpPort [int]
EmailNotifySmtpSenderName [string]
EmailNotifySmtpSenderEmail [string]
EmailNotifyWhenNewUpdatesAreSync [boolean]
EmailNotifyWhenNewUpdatesAreSyncRecipients [string[]]
EmailNotifySendStatusReports [boolean]
EmailNotifySendStatusReportsFrecuency
EmailNotifySendStatusReportsTime[string]
EmailNotifySendStatusReportsRecipients [string[]]
Assuming the current state config of WSUS server:
Name Value
---- -----
Products {Office, Windows}
UpstreamServerSSL
SynchronizeAutomatically True
ContentDir C:\WSUS
UpstreamServerName
UpstreamServerReplica
SynchronizationsPerDay 1
UpstreamServerPort
ProxyServerBasicAuthentication
Ensure Present
Classifications {e6cf1350-c01b-414d-a61f-263d14d133b4, e0789628-ce08-4437-be74-2495b842f43b}
ProxyServerName
SQLServer MICROSOFT##WID
Languages {fr, en}
ProxyServerPort
UpdateImprovementProgram False
ClientTargetingMode Client
SynchronizeAutomaticallyTim... 21:00:00
ProxyServerCredentialUsername
When running the following code:
$InvokeParams = @{Name = 'UpdateServicesServer'; Method = 'get'; Property = @{ensure = 'present' }; ModuleName = @{ModuleName = 'C:/Program Files/WindowsPowerShell/Modules/UpdateServicesDsc/1.2.1/UpdateServicesDsc.psd1'; RequiredVersion = '1.2.1' } }
$Result = Invoke-DscResource @InvokeParams -Verbose
$Result
An error comes up as follows
A general error occurred that is not covered by a more specific error code.
+ CategoryInfo : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
+ FullyQualifiedErrorId : MI RESULT 1
+ PSComputerName : localhost
It was identified that the issue was due to the return value for the language being of type StringCollection rather than String[] as per the schema for the UpdateServicesServer resource:
[Write, Description("Update languages, * for all.")] String Languages[];
But the current return value is equivalent to the following:
PS C:\Users\Administrator> (Get-WsusServer).GetConfiguration().GetEnabledUpdateLanguages().GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True StringCollection System.Object
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = Resourceget,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer EC2AMAZ-DUA1E4V with user sid S-1-5-21-2052935279-2926737905-346181576-500.
VERBOSE: [EC2AMAZ-DUA1E4V]: [[UpdateServicesServer]DirectResourceAccess] Getting WSUS server.
VERBOSE: [EC2AMAZ-DUA1E4V]: [[UpdateServicesServer]DirectResourceAccess] WSUS server is Present.
VERBOSE: [EC2AMAZ-DUA1E4V]: [[UpdateServicesServer]DirectResourceAccess] Getting WSUS server configuration.
VERBOSE: [EC2AMAZ-DUA1E4V]: [[UpdateServicesServer]DirectResourceAccess] Getting WUSS server subscription.
VERBOSE: [EC2AMAZ-DUA1E4V]: [[UpdateServicesServer]DirectResourceAccess] Getting WSUS SQL server.
VERBOSE: [EC2AMAZ-DUA1E4V]: [[UpdateServicesServer]DirectResourceAccess] WSUS Server SQL Server is MICROSOFT##WID.
VERBOSE: [EC2AMAZ-DUA1E4V]: [[UpdateServicesServer]DirectResourceAccess] Getting WSUSServer content directory.
VERBOSE: [EC2AMAZ-DUA1E4V]: [[UpdateServicesServer]DirectResourceAccess] WSUS Server content directory is C:\WSUS.
VERBOSE: [EC2AMAZ-DUA1E4V]: [[UpdateServicesServer]DirectResourceAccess] Getting WSUSServer update improvement program.
VERBOSE: [EC2AMAZ-DUA1E4V]: [[UpdateServicesServer]DirectResourceAccess] WSUS Server content update improvement program is False.
VERBOSE: [EC2AMAZ-DUA1E4V]: [[UpdateServicesServer]DirectResourceAccess] Getting WSUS Server languages.
VERBOSE: [EC2AMAZ-DUA1E4V]: [[UpdateServicesServer]DirectResourceAccess] WSUS Server languages are System.Collections.Specialized.StringCollection.
VERBOSE: [EC2AMAZ-DUA1E4V]: [[UpdateServicesServer]DirectResourceAccess] Getting WSUS Server Classifications.
VERBOSE: [EC2AMAZ-DUA1E4V]: [[UpdateServicesServer]DirectResourceAccess] WSUS Server Classifications are e6cf1350-c01b-414d-a61f-263d14d133b4.
VERBOSE: [EC2AMAZ-DUA1E4V]: [[UpdateServicesServer]DirectResourceAccess] Getting WSUS Server products.
VERBOSE: [EC2AMAZ-DUA1E4V]: [[UpdateServicesServer]DirectResourceAccess] WSUS Server products are Office.
VERBOSE: [EC2AMAZ-DUA1E4V]: [[UpdateServicesServer]DirectResourceAccess] Getting WSUSServer synchronization settings.
VERBOSE: [EC2AMAZ-DUA1E4V]: [[UpdateServicesServer]DirectResourceAccess] WSUS Server synchronize automatically is True.
VERBOSE: [EC2AMAZ-DUA1E4V]: [[UpdateServicesServer]DirectResourceAccess] WSUS Server synchronize automatically time of day is 21:00:00.
VERBOSE: [EC2AMAZ-DUA1E4V]: [[UpdateServicesServer]DirectResourceAccess] WSUSServer number of synchronizations per day is 1.
VERBOSE: [EC2AMAZ-DUA1E4V]: [[UpdateServicesServer]DirectResourceAccess] WSUSServer client targeting mode is Client.
A general error occurred that is not covered by a more specific error code.
+ CategoryInfo : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
+ FullyQualifiedErrorId : MI RESULT 1
+ PSComputerName : localhost
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 3.862 seconds
The following code in the function Get-TargetResource
has been found to be the cause of the issue:
if ($WsusConfiguration.AllUpdateLanguagesEnabled)
{
$Languages = @('*')
}
else
{
$Languages = $WsusConfiguration.GetEnabledUpdateLanguages()
}
Write-Verbose -Message ($script:localizedData.WsusLanguages -f $Languages)
The suggested fix to the issue is as follows:
if ($WsusConfiguration.AllUpdateLanguagesEnabled)
{
$Languages = @('*')
}
else
{
$Languages = [String[]]$WsusConfiguration.GetEnabledUpdateLanguages()
}
Write-Verbose -Message ($script:localizedData.WsusLanguages -f ($Languages -join ','))
OsName : Microsoft Windows Server 2019 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture : 64-bit
WindowsVersion : 1809
WindowsBuildLabEx : 17763.1.amd64fre.rs5_release.180914-1434
OsLanguage : en-US
OsMuiLanguages : {en-US}
Name Value
---- -----
PSVersion 5.1.17763.3770
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.3770
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Name Version Path
---- ------- ----
UpdateServicesDsc 1.2.1 C:\Program Files\WindowsPowerShell\Modules\UpdateServicesDsc\1.2.1\UpdateServicesDsc.psd1
On line 663 in the Set-TargetResource
function, the following call is made:
New-InvalidResultException -Message $errorMessage -ErrorRecord $_
However, unlike previous calls to similar commands (see line 416), this command is not inside a try/catch block. Therefore, the $_
variable is null and the function errors out without detailing the resource failure. Instead, it leads the user on a wild goose chase tracking down $null values. See #58 for an example.
Proposals:
$_
with a meaningful value such as "Set-TargetResource has been run. However, the resource is not in the desired state. The following parameters are not set to the desired values: ..."I prefer option 2, as the Set function has already performed its work and the state has already changed. The Unit and Integration tests should be providing feedback as to the effectiveness of the Set function, not the Set function itself. If, on subsequent execution of the configuration block, the test continues to fail and Set-TargetResource
continues to be called, then an issue with the Set-TargetResource
function should be filed and addressed.
Additionally, Issues #45 and #47 are related to apparent false negatives related to the Set-TargetResource
calling Test-TargetResource
See #58
See #58
v1.2.1
This is for both the UpdateServicesServer and UpdateServicesApprovalRule resources:
The Products
property currently accepts friendly names while Classifications
accepts GUIDs. GUIDs are not overly easy to work with. Given that there's already code to translate Titles to GUIDs for Products, the same approach could be used for Classifications as well.
I am aware that this has already been discussed in #18
To avoid language dependency, as well as to avoid the introduction of breaking change, the properties could be made to accept both friendly names as well as GUIDs. The desired values could be compared against Title or ID.
# This works OK
Configuration WSUSProduct {
Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
Import-DscResource -ModuleName 'UpdateServicesDsc' -ModuleVersion 1.2.1
Node localhost {
UpdateServicesServer WSUS {
Ensure = 'Present'
Languages = 'en'
# Classification must be a GUID
Classifications = '0fa1201d-4330-4fa8-8ae9-b877473b6441' # Security Updates
# Products use Title
Products = 'Windows Server 2016'
}
}
}
# This does not work
Configuration WSUSProduct {
Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
Import-DscResource -ModuleName 'UpdateServicesDsc' -ModuleVersion 1.2.1
Node localhost {
UpdateServicesServer WSUS {
Ensure = 'Present'
Languages = 'en'
# Title can't be used in Classifications
Classifications = 'Security Updates'
# GUIDs can't be used in Products
Products = '569e8e8f-c6cd-42c8-92a3-efbb20a0f6f5' # Windows Server 2016
}
}
}
OsName : Microsoft Windows Server 2019 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture : 64-bit
WindowsVersion : 1809
WindowsBuildLabEx : 17763.1.amd64fre.rs5_release.180914-1434
OsLanguage : en-US
OsMuiLanguages : {en-US}
Name Value
---- -----
PSVersion 5.1.17763.1490
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.1490
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Name Version Path
---- ------- ----
UpdateServicesDsc 1.2.1 C:\Program Files\WindowsPowerShell\Modules\UpdateServicesDsc\1.2.1\UpdateServicesDsc.psd1
The UpdateServicesServer Classification property should use the Classification Title, not the GUID. This makes the DSC configuration file both easier to read and easier to maintain.
The issue seems to happen when I try to put more than one language using a string array. It works fine for one language or "*" but as soon as I use an array with multiple languages the following happens :
No matter if the inital test of the ressource is true or false, it will go for the set script (even if languages are already in the desired state, in which case each language can be seen in the verbose log).
When the set script is applied, it goes without errors and WSUS configuration is actually changed to the desired language parameter.
The final test script returns false in any case, making the whole run return in error.
VERBOSE: [MyServerName]: LCM: [ Start Resource ] [[UpdateServicesServer]WSUS_Service]
VERBOSE: [MyServerName]: LCM: [ Start Test ] [[UpdateServicesServer]WSUS_Service]
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Getting WSUSServer
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] WSUSServer is Present
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Getting WSUSServer configuration
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Getting WSUSServer subscription
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Getting WSUSServer SQL Server
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] WSUSServer SQL Server is MICROSOFT##WID
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Getting WSUSServer content directory
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] WSUSServer content directory is F:\WSUS
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Getting WSUSServer update improvement program
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] WSUSServer content update improvement program is False
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Getting WSUSServer upstream server
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] WSUSServer upstream server is upstream.domain.com,
port 8530, use SSL False, replica True
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Getting WSUSServer languages
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] WSUSServer languages are fr
en
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Getting WSUSServer classifications
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] WSUSServer classifications are e6cf1350-c01b-414d-a61f-263d14d133b4 e0789628-ce08-4437-be74-2495b842f43b 0fa1201d-4330-4fa8-8ae9-b877473b6441
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Getting WSUSServer products
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] WSUSServer products are Office Windows
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Getting WSUSServer synchronization settings
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] WSUSServer synchronize automatically is True
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] WSUSServer synchronize automatically time of day is 00:00:00
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] WSUSServer number of synchronizations per day is 1
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] WSUSServer client targeting mode is Client
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Languages test failed
VERBOSE: [MyServerName]: LCM: [ End Test ] [[UpdateServicesServer]WSUS_Service] in 2.2350 seconds.
VERBOSE: [MyServerName]: LCM: [ Start Set ] [[UpdateServicesServer]WSUS_Service]
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Configuring WSUS
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Check for previous configuration change
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Configuring WSUS Update Improvement Program
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Configuring WSUS Upstream Server
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Configuring WSUS no proxy server
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Setting WSUS languages
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Setting WSUS products
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Setting WSUS classifications
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Setting WSUS synchronization schedule
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Getting WSUSServer
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] WSUSServer is Present
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Getting WSUSServer configuration
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Getting WSUSServer subscription
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Getting WSUSServer SQL Server
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] WSUSServer SQL Server is MICROSOFT##WID
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Getting WSUSServer content directory
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] WSUSServer content directory is F:\WSUS
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Getting WSUSServer update improvement program
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] WSUSServer content update improvement program is False
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Getting WSUSServer upstream server
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] WSUSServer upstream server is upstream.domain.com,
port 8530, use SSL False, replica True
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Getting WSUSServer languages
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] WSUSServer languages are fr
en
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Getting WSUSServer classifications
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] WSUSServer classifications are e6cf1350-c01b-414d-a61f-263d14d133b4 e0789628-ce08-4437-be74-2495b842f43b 0fa1201d-4330-4fa8-8ae9-b877473b6441
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Getting WSUSServer products
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] WSUSServer products are Office Windows
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Getting WSUSServer synchronization settings
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] WSUSServer synchronize automatically is True
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] WSUSServer synchronize automatically time of day is 00:00:00
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] WSUSServer number of synchronizations per day is 1
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] WSUSServer client targeting mode is Client
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Languages test failed
VERBOSE: [MyServerName]: [[UpdateServicesServer]WSUS_Service] Test-TargetResouce returned false after calling set. | ErrorType: MSFT_UpdateServicesServer.TestFailedAfterSet
VERBOSE: [MyServerName]: LCM: [ End Set ] [[UpdateServicesServer]WSUS_Service] in 0.7030 seconds.
PowerShell DSC resource MSFT_UpdateServicesServer failed to execute Set-TargetResource functionality with error message: Test-TargetResouce returned false after calling set.
+ CategoryInfo : InvalidOperation: (:) [], CimException
+ FullyQualifiedErrorId : ProviderOperationExecutionFailure
+ PSComputerName : localhost
UpdateServicesServer "WSUS_Service" {
Ensure = "Present"
ContentDir = "F:\WSUS"
Languages = $Languages # This is a verified string array
UpdateImprovementProgram = $false
SynchronizeAutomatically = $true
SynchronizationsPerDay = 1
SynchronizeAutomaticallyTimeOfDay = (New-TimeSpan -Hours 0).ToString()
UpstreamServerName = "upstream.domain.com"
UpstreamServerPort = 8530
UpstreamServerReplica = $true
DependsOn = @("[WindowsFeature]WSUS_Feature", "[File]WSUS_Folder")
}
In the previous DSC log the desired languages are "fr" and "en".
OsName : Microsoft Windows Server 2019 Standard
OsOperatingSystemSKU : StandardServerEdition
OsArchitecture : 64-bit
WindowsVersion : 1809
WindowsBuildLabEx : 17763.1.amd64fre.rs5_release.180914-1434
OsLanguage : en-US
OsMuiLanguages : {en-US}
Name Value
---- -----
PSVersion 5.1.17763.771
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.771
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
1.1.0.0
Loading new products into an array under "UpdateServicesServer" DSC resource has failed due to WSUS now containing multiple product titles with the same name.
ERROR - An error occurred running method 'Set' in resource 'UpdateServicesServer' for resourceID '[UpdateServicesServer]UpdateServices': System.Management.Automation.MethodException: Cannot find an overload for "GetUpdateCategory" and the argument count: "1".
Modify this code block to handle product names with the same title Code Reference
Not sharing the DSC configuration, since it's an array of products. But here is the example of multiple products returned from the $AllWsusProducts = $WsusServer.GetUpdateCategories() line that is pulling duplicate product titles.
Title Description
----- -----------
Windows Server 2016 Windows 10 Server
Windows Server 2016 Windows Server 2016
Windows Server 2019 and later, Servicing Drivers Windows Server 2019 and later, Servicing Drivers
Windows Server 2019 and later, Upgrade & Servicing Drivers Windows Server 2019 and later, Upgrade & Servicing Drivers
Windows Server 2019 Datacenter: Azure Edition Hotpatch Windows Server 2019 Datacenter: Azure Edition
Windows Server 2019 Category for Windows Server 2019
Windows Server 2019 Windows Server 2019 (RS5 Server) and above
OsName : Microsoft Windows Server 2019 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture : 64-bit
WindowsVersion : 1809
WindowsBuildLabEx : 17763.1.amd64fre.rs5_release.180914-1434
OsLanguage : en-US
OsMuiLanguages : {en-US}
Name Value
---- -----
PSVersion 5.1.17763.1490
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.1490
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
1.2.0
Verbose output of Languages property is broken in Test-TargetResource
, it returns System.Collections.Specialized.StringCollection
instead of list of languages
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Mi
crosoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer SRV1 with user sid S-1-5-21-2574420874-2490326428-1586090461-500.
VERBOSE: [SRV1]: LCM: [ Start Set ]
VERBOSE: [SRV1]: LCM: [ Start Resource ] [[UpdateServicesServer]WSUS]
VERBOSE: [SRV1]: LCM: [ Start Test ] [[UpdateServicesServer]WSUS]
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WSUS server.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUS server is Present.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WSUS server configuration.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WUSS server subscription.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WSUS SQL server.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUS Server SQL Server is MICROSOFT##WID.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WSUSServer content directory.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUS Server content directory is E:\.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WSUSServer update improvement program.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUS Server content update improvement program is False.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] Getting WSUS Server languages.
VERBOSE: [SRV1]: [[UpdateServicesServer]WSUS] WSUS Server languages are System.Collections.Specialized.StringCollection.
...
Adjust line 124 to:
$Languages = ($WsusConfiguration.GetEnabledUpdateLanguages()) -join ','
...to transform the string collection into a simple string.
Configuration WSUSProduct {
Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
Import-DscResource -ModuleName 'UpdateServicesDsc' -ModuleVersion 1.2.1
Node localhost {
UpdateServicesServer WSUS {
Ensure = 'Present'
Languages = 'en'
Products = 'Windows Server 2016'
}
}
}
OsName : Microsoft Windows Server 2019 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture : 64-bit
WindowsVersion : 1809
WindowsBuildLabEx : 17763.1.amd64fre.rs5_release.180914-1434
OsLanguage : en-US
OsMuiLanguages : {en-US}
Name Value
---- -----
PSVersion 5.1.17763.1490
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.1490
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Name Version Path
---- ------- ----
UpdateServicesDsc 1.2.1 C:\Program Files\WindowsPowerShell\Modules\UpdateServicesDsc\1.2.1\UpdateServicesDsc.psd1
The initial sync WSUS.cab
file is out of date and is missing Windows Server 2019
and other products.
The following snippet fails because Windows Server 2019
is not a known product.
UpdateServicesServer 'UpdateServices' {
Synchronize = $false # Default, use WSUS.cab
Products = @(
'Windows Server 2019'
)
...
[[UpdateServicesServer]UpdateServices] Products test failed
[[UpdateServicesServer]UpdateServices] Test-TargetResouce returned false after calling set. | ErrorType: MSFT_UpdateServicesServer.TestFailedAfterSet
After a full sync, Windows Server 2019
product can be used.
Please update bundled WSUS metadata export in WSUS.cab
See above.
Windows Server 2019
5.1.17763.1007
UpdateServicesDsc 1.1.0.0
The code coverage of pester tests is arround 50%.
To improve the quality of this resource, the code coverage need to be up to 80% and use v5 of pester.
UpdateServicesServer: Set-TargetResource mistype in check #ClientTargetingMode
spaces in "Client Targeting Mode", wherefore test is failing and DSC is throwing error
#ClientTargetingMode
if($PSBoundParameters.ContainsKey("Client Targeting Mode"))
Merge dev branch which has correct syntax to master branch.
master
It would be great to be able to have the post install feature in desired state. Currently using the dirty DSC script resource below to do the job.
Script WSUSPostInstall
{
DependsOn = '[File]WSUSContentDirectory'
GetScript = {
@{
GetScript = $GetScript
SetScript = $SetScript
TestScript = $TestScript
Result = ($null -ne (Get-Website -Name 'WSUS Administration') -and (Test-Path -Path "$($Using:Node.ServicesVolume)\WSUS\WsusContent\anonymousCheckFile.txt"))
}
}
SetScript = {
& 'C:\Program Files\Update Services\Tools\WsusUtil.exe' postinstall CONTENT_DIR=$($Using:Node.ServicesVolume)\WSUS
}
TestScript = {
$Status = ($null -ne (Get-Website -Name 'WSUS Administration') -and (Test-Path -Path "$($Using:Node.ServicesVolume)\WSUS\WsusContent\anonymousCheckFile.txt"))
$Status -eq $True
}
}
Examples should be added to show how to use the resources.
Can you please rename the repo by clicking Settings, typing in "WSUSDsc", then clicking Rename.
Just curious but why do you remove default products and classifications before initial sync?
Please connect this repo at https://reviewable.io/repositories so that all PRs get linked to reviews. Thanks!
Please connect this repo at https://reviewable.io/repositories so that all PRs get linked to reviews. Thanks!
On attempting to remove a rule I got this error:
VERBOSE: [SESTO869]: LCM: [ Start Resource ] [[UpdateServicesApprovalRule]RemoveDefaultApprovalRule]
VERBOSE: [SESTO869]: LCM: [ Start Test ] [[UpdateServicesApprovalRule]RemoveDefaultApprovalRule]
VERBOSE: [SESTO869]: [[UpdateServicesApprovalRule]RemoveDefaultApprovalRule] Identified WSUS
server information: Microsoft.UpdateServices.Internal.BaseApi.UpdateServer
VERBOSE: [SESTO869]: [[UpdateServicesApprovalRule]RemoveDefaultApprovalRule] Ensure test
failed
VERBOSE: [SESTO869]: LCM: [ End Test ] [[UpdateServicesApprovalRule]RemoveDefaultApprovalRule] in 0.4360
seconds.
VERBOSE: [SESTO869]: LCM: [ Start Set ] [[UpdateServicesApprovalRule]RemoveDefaultApprovalRule]
VERBOSE: [SESTO869]: [[UpdateServicesApprovalRule]RemoveDefaultApprovalRule] Failed during
creation of approval rule Default Automatic Approval Rule
VERBOSE: [SESTO869]: LCM: [ End Set ] [[UpdateServicesApprovalRule]RemoveDefaultApprovalRule] in 0.2810
seconds.
PowerShell DSC resource MSFT_UpdateServicesApprovalRule failed to execute Set-TargetResource functionality with error
message: Cannot convert argument "ruleId", with value: "Default Automatic Approval Rule", for "DeleteInstallApprovalRul
e" to type "System.Int32": "Cannot convert value "Default Automatic Approval Rule" to type "System.Int32". Error: "Inpu
t string was not in a correct format.""
+ CategoryInfo : InvalidOperation: (:) [], CimException
+ FullyQualifiedErrorId : ProviderOperationExecutionFailure
+ PSComputerName : SESTO869
When looking at the function signature of DeleteInstallApprovalRule it seems like it accepts the ruleId and not the name:
TypeName : Microsoft.UpdateServices.Internal.BaseApi.UpdateServer
Name : DeleteInstallApprovalRule
MemberType : Method
Definition : void DeleteInstallApprovalRule(int ruleId), void IUpdateServer.DeleteInstallApprovalRule(int ruleId)
And here's the calling code
DSCResources/MSFT_UpdateServicesApprovalRule/MSFT_UpdateServicesApprovalRule.psm1 - Row 242
"Absent"
{
$WsusServer.DeleteInstallApprovalRule($Name)
}
Verbose output of Get-TargetResource
returns Microsoft.UpdateServices.Internal.BaseApi.UpdateServer
instead of WSUS server name
VERBOSE: [SRV1]: LCM: [ Start Resource ] [[UpdateServicesApprovalRule]Approval]
VERBOSE: [SRV1]: LCM: [ Start Test ] [[UpdateServicesApprovalRule]Approval]
VERBOSE: [SRV1]: [[UpdateServicesApprovalRule]Approval] Identified WSUS server information: Microsoft.UpdateServices.Internal.BaseApi.UpdateServer
VERBOSE: [SRV1]: LCM: [ End Test ] [[UpdateServicesApprovalRule]Approval] in 0.0470 seconds.
VERBOSE: [SRV1]: LCM: [ Skip Set ] [[UpdateServicesApprovalRule]Approval]
VERBOSE: [SRV1]: LCM: [ End Resource ] [[UpdateServicesApprovalRule]Approval]
Change the line to:
Write-Verbose -Message ('Identified WSUS server information: {0}' -f $WsusServer.Name)
Configuration WSUSProduct {
Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
Import-DscResource -ModuleName 'UpdateServicesDsc' -ModuleVersion 1.2.1
Node localhost {
UpdateServicesApprovalRule Approval {
Ensure = 'Present'
Name = 'Test Approval Rule'
Classifications = @(
# Updates
'cd5ffd1e-e932-4e3a-bf74-18bf0b1bbd83'
)
Products = 'Windows Server 2016'
ComputerGroups = 'All Computers'
Enabled = $true
}
}
}
OsName : Microsoft Windows Server 2019 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture : 64-bit
WindowsVersion : 1809
WindowsBuildLabEx : 17763.1.amd64fre.rs5_release.180914-1434
OsLanguage : en-US
OsMuiLanguages : {en-US}
Name Value
---- -----
PSVersion 5.1.17763.1490
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.1490
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Name Version Path
---- ------- ----
UpdateServicesDsc 1.2.1 C:\Program Files\WindowsPowerShell\Modules\UpdateServicesDsc\1.2.1\UpdateServicesDsc.psd1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.