How to Create a New User With DSC

Goal: You are trying to use PowerShell's DSC to create a new local user.
Problem:  An .mof file will not be created because the code will not compile.  You will get an error message like this when you try to run the .ps1 file.
"ConvertTo-MOFInstance: System.InvalidOperationException error processing property 'Password' OF TYPE 'User': Converting and storing an encrypted password as plaintext is allowed only if PSDscaAllowPlainTextPassword is set to True...
ConvertTo-MOFInstance $keywordName $canonicalizedValue"
Errors occurred while processing coinfiguration ... PSDesiredStateConfiguration.psm1:2088 ... InvalidOperationException..."

Solution:  We found a good article for creating new users with DSC.  It has a few typos and one serious problem here.
We found this serious problem with the .ps1 code:
"newLocalAdmin -ConfigurationData $Config"
This line above should be this:
"newLocalAdmin -ConfigurationData $ConfigData"

Leave a comment

Your email address will not be published. Required fields are marked *