question

KarthikShanmugam-1366 avatar image
0 Votes"
KarthikShanmugam-1366 asked Soccan commented

Unable to install packages with DSC configuration- Server 2019

Hi Team,

I am trying to install packages using PackageManagement (DSC resource). The below mentioned script works fine in Server 2016 and installs required packages. But in Windows server 2019 I am getting errors like ValidateNodeResources : Resource '[PackageManagementSource]PSGallery' required by
'[PackageManagement]xWebAdministration' does not exist. Please ensure that the required resource exists and the name
is properly formed

Not sure if there is anything blocking on 2019 server which is allowed in 2016 server. Kindly advise.

Script:

Configuration mypackages
{
Import-DscResource -Name PackageManagementSource
Import-DSCResource -Name PackageManagement
node localhost

 {
 
     PackageManagement xWebAdministration
     {
         Ensure               = "Present"
         Name                 = "xWebAdministration"
         Source               = "PSGallery"
         DependsOn            = "[PackageManagementSource]PSGallery"
     }
     PackageManagement xPSDesiredStateConfiguration
     {
         Ensure               = "Present"
         Name                 = "xPSDesiredStateConfiguration"
         Source               = "PSGallery"
         DependsOn            = "[PackageManagementSource]PSGallery"
     }
 }

}
$config = mypackages -Verbose
Start-DscConfiguration -Wait -Verbose -force -Path $config.PsParentPath

windows-server-powershellwindows-server-management
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Soccan avatar image
0 Votes"
Soccan answered Soccan commented

The resource you are depending on, "[PackageManagementSource]PSGallery", where is that coming from, is that from another configuration that should already have been applied? For my eyes it seems that you are depending on a piece of configuration that is not there....

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Soccan,

I had executed PackageManagement installation in a separate script to ensure the machine has latest PackageManagement module installed.
This is the second script which works without any issue on 2016 server but not on 2019 server.
By default PackageManagementSource is inclusive of PackageManagement as per the MS docs below.
I notices Invoke cim method populating immediately on 2016 while executing this script, but it wasn't happening on 2019 server. Please advise.

https://docs.microsoft.com/en-us/powershell/scripting/dsc/reference/resources/packagemanagement/packagemanagementsourcedscresource?view=powershell-7

0 Votes 0 ·
Soccan avatar image Soccan KarthikShanmugam-1366 ·

Yeah, I expected you to have done that...

Sounds like a very strange behavior from Invoke-CimMethod... It should behave equal on both versions. To be honest I've mainly jacked into DSC from Puppet, so some of the logic was handled by Puppet, but if this would be related to what you describe of Invoke-CimMethod I would think I would have run into it anyways.
I can not come up with any further idea, from my viewpoint I think what you are doing should work equaly on both machines...

0 Votes 0 ·