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:

    Try using the User resource from PSDscResources instead of PSDesiredStateConfiguration.

    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:

    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