PSDscResources icon indicating copy to clipboard operation
PSDscResources copied to clipboard

Registry Resource Fails when using a credential with a blank password

Open lanatmwan opened this issue 6 years ago • 1 comments

It is common for Kiosk type devices to have a local account that has no password to run whatever the main kiosk app is. It also common for said devices to need registry customizations, some set under the local kiosk user's context. I would like to use DSC to audit/fix those settings as necessary but the Registry resource gets a null reference if the password for the user is blank.

The easiest way to demonstrate it is with the generated mof excerpt:

instance of MSFT_Credential as $MSFT_Credential1ref
{
    Password = "";
    UserName = "Foo";
};

instance of MSFT_RegistryResource as $MSFT_RegistryResource1ref
{
 ResourceID = "[Registry]Registry Accessibility Warning Sounds";
 ValueName = "Warning Sounds";
 PsDscRunAsCredential = $MSFT_Credential1ref;
 Key = "HKEY_USERS\\Foo\\Control Panel\\Accessibility";
 Ensure = "Present";
 Force = True;
 SourceInfo = "::166::21::Registry";
 ValueType = "DWord";
 ModuleName = "PSDscResources";
 ValueData = {
    "0"
 };
 ModuleVersion = "2.12.0.0";
 ConfigurationName = "FooRegistryKeys";
};

If I put a password into the credential, I get the expected invalid password message but with the correct blank password I get:

PowerShell DSC resource MSFT_RegistryResource failed to execute Test-TargetResource functionality with error message: Object reference not set to an instance of an object. + CategoryInfo : InvalidOperation: (root/Microsoft/...gurationManager:String) [], CimException + FullyQualifiedErrorId : ProviderOperationExecutionFailure + PSComputerName : localhost

lanatmwan avatar Oct 30 '19 20:10 lanatmwan

Thanks for raising this @lanatmwan - we'll need to figure out if this is a limitation with the resource or with DSC itself. Are you able to share your DSC Config as well?

PlagueHO avatar Nov 02 '19 01:11 PlagueHO