5
votes

I have a simple PowerShell DSC configuration block that ensures that a user account does not exist, and when I attempt to apply it to the local system using Start-DscConfiguration, I am receiving an error message similar to the following:

The WS-Management service cannot process the request. The WMI service returned an 'access denied' error.

How can I apply the DSC configuration successfully?

Here is the configuration block I am using:

configuration MyConfig {
    User Trevor2 {
        UserName = 'Trevor2';
        Ensure = 'Absent';
    }
}

$Path = 'c:\dsc\MyConfig';
MyConfig -OutputPath $Path;

Start-DscConfiguration -Wait -Verbose -Path $Path;
# Clean up MOF files
Remove-Item -Path $Path -Recurse;
1

1 Answers

8
votes

Make sure that the PowerShell console host or PowerShell Integrated Scripting Editor (ISE) is running under your administrative Windows token, if UAC is enabled. Applying PowerShell DSC configurations requires that you be an Administrator by default.