none
Creating local users inside a container RRS feed

  • Question

  • When trying to create a local user inside a container using powershell DSC (MSFT_UserResource.psm1) an error occurs.

    PowerShell DSC resource MSFT_UserResource  failed to execute Test-TargetResource functionality with error message: There could be a possible connection error while trying to use the System.DirectoryServices API's.Exception calling "FindByIdentity" with "2" argument(s): "The Server service is not started

    This seems to be come from the following line:

    $user = [System.DirectoryServices.AccountManagement.UserPrincipal]::FindByIdentity($principalContext, $UserName);
    Is creating a user different inside a container?

    Thursday, February 18, 2016 11:55 AM

All replies

  • Just came accross this myself. It seems the answer might be:

    https://github.com/PowerShell/DscResources/issues/235

    Try using the User resource from PSDscResources instead of PSDesiredStateConfiguration. https://www.powershellgallery.com/packages/PSDscResources/2.3.0.0

    Monday, April 9, 2018 3:47 PM
  • Even after trying PSDscResources - I still had the same problem.

    I then tried swithing to a script resource and using New-LocalUser - however that had a problem with secure string: https://social.msdn.microsoft.com/Forums/en-US/e51acf07-8d85-467d-9d2c-fb07ddd482c7/newlocaluser-with-securestring-password-throws-cryptographicexception-the-system-cannot-find-the?forum=windowscontainers

    So the only way I could get this to work in the end was to use `net user /Add`

    Tuesday, April 10, 2018 10:27 AM