PowerShell / PSDscResources

MIT License
129 stars 53 forks source link

User: Only set the Password and PasswordChangeRequired when creating a new user #167

Open tobukc opened 5 years ago

tobukc commented 5 years ago

Is it possible to check and set the Password and PasswordChangeRequired only when creating a new user? I only want to set the initial password and force users to change it after login. If the user exists, I don't want to update these two properties. Thanks!

mhendric commented 5 years ago

Hi @phelucko. The Password value is actually tested to be correct or not, so I think if you used that to create a new user, subsequent runs of the script wouldn't try to change the password again, unless the password had changed through some other means, at which point the DSC resource would set it back. Per code comments though, it looks like PasswordChangeRequired isn't actually testable though (or at least wasn't for the developer), which means if that is in a script, it's going to kick in every time you run the script.

If we did want to change behavior here, I think that would be considered a breaking change, which isn't allowed in PSDscResources. The better place to implement a change like this would be in https://github.com/PowerShell/xPSDesiredStateConfiguration.