Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

User resource requires "Server" service to be running to run #235

Closed
artisticcheese opened this issue Dec 21, 2016 · 1 comment
Closed
Labels
external The issue cannot be resolved within the DSC Resource Kit.

Comments

@artisticcheese
Copy link

If "server" service is not running it's impossible to run DSC resource "user" to set local user. Sample code and error is below. This happens inside Windows 2016 container which has "server" service disabled.

Configuration LocalAdmin
 {  param(
     [pscredential] $cred
 )
    Import-DscResource -ModuleName 'PSDesiredStateConfiguration' 
    node localhost{
    User LocalAdmin   {
            UserName =  "blah"
            Description =  "Customized admin for container"
            Ensure = "Present"
            Password = $cred
    }
    }
    
}
 $cd = @{
    AllNodes = @(
        @{
            NodeName = 'localhost'
            PSDscAllowPlainTextPassword = $true
        }
    )
}
$cred = [pscredential]::new("blah", (ConvertTo-SecureString  "A123456!" -AsPlainText -Force)) 
LocalAdmin -cred $cred -ConfigurationData $cd 
Start-DscConfiguration -Wait -Verbose -Path .\Localadmin -Force

When being run following error is being logged

VERBOSE: [0C24321CED0E]: LCM:  [ Start  Set      ]
VERBOSE: [0C24321CED0E]: LCM:  [ Start  Resource ]  [[User]LocalAdmin]
VERBOSE: [0C24321CED0E]: LCM:  [ Start  Test     ]  [[User]LocalAdmin]
The variable '$user' cannot be retrieved because it has not been set.
    + CategoryInfo          : InvalidOperation: (user:) [], CimException
    + FullyQualifiedErrorId : VariableIsUndefined
    + PSComputerName        : localhost

VERBOSE: [0C24321CED0E]: LCM:  [ End    Test     ]  [[User]LocalAdmin]  in 0.6720 seconds.
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.
"
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : ProviderOperationExecutionFailure
    + PSComputerName        : localhost

VERBOSE: [0C24321CED0E]: 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 4.579 seconds
@kwirkykat kwirkykat added the external The issue cannot be resolved within the DSC Resource Kit. label Jan 18, 2017
@kwirkykat
Copy link
Member

@artisticcheese Try using the User resource from PSDscResources instead of PSDesiredStateConfiguration. https://www.powershellgallery.com/packages/PSDscResources/2.3.0.0
If the error still occurs with that resource, please open an issue in PSDscResources. https://github.com/powershell/psDSCResources/issues

This is specific to the PSDscResources repository, so I am closing it as external to the DscResources repository.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
external The issue cannot be resolved within the DSC Resource Kit.
Projects
None yet
Development

No branches or pull requests

2 participants