Open dk-ebeisecker opened 1 year ago
Verify that these lines work setting the variable $user
.
The first line fails
PS C:\> $principalContext = New-Object System.DirectoryServices.AccountManagement.PrincipalContext -ArgumentList ([System.DirectoryServices.AccountManagement.ContextType]::Machine)
Unable to find type [System.DirectoryServices.AccountManagement.ContextType].
At line:1 char:107
+ ... gumentList ([System.DirectoryServices.AccountManagement.ContextType]: ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Director...ent.ContextType:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
So then the current implementation is not supported in a container.
The following line is used on a Nano server, does it work in the container?
If that works, can you see what this outputs?
(Get-CimInstance -ClassName Win32_OperatingSystem).OperatingSystemSKU
Yes, that line works fine inside the container
PS C:\> [Microsoft.PowerShell.Commands.LocalUser] $user = Get-LocalUser -Name 'Guest' -ErrorAction Stop
PS C:\> $user
Name Enabled Description
---- ------- -----------
Guest False Built-in account for guest access to the computer/domain
PS C:\> (Get-CimInstance -ClassName Win32_OperatingSystem).OperatingSystemSKU
8
Okay so then the resource might need to switch to the same logic as used in a Nano server.
Looking at the list of SKUs here https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-operatingsystem the container reports as a normal Desktop Experience. Must be some other why to determine that it runs in a container. 🤔
But if you want to test out the full functionality of when running in Nano (might be other problems) you could replace the following lines in your local installed module to if ($true)
so the Nano-logic is ran.
So what we need is new logic to test if running in a container and then run the same logic as Nano (if it works) or other logic that is needed for a Windows container.
Problem description
When I attempt to run the
xUser
resource inside a Docker build of Windows 2022 Server Core, I get the following errorDocker image mcr.microsoft.com/windows/servercore ltsc2022 b53d206693f6
Verbose logs
DSC configuration
Suggested solution
I'm not sure what the problem is
Operating system the target node is running
PowerShell version and build the target node is running
xPSDesiredStateConfiguration version