Reputation: 3029
I need to be able to change the PasswordNeverExpires option in the Local User Group properties area.
I already know that I will have to use a flag in order to perform this action as stated in the article:
How to use the UserAccountControl flags to manipulate user account properties
How would I be able to target the user in question through a Powershell script?
Thanks
Upvotes: 3
Views: 22916
Reputation: 131
This will also work.
Set-LocalUser -Name "Administrator" -PasswordNeverExpires:$true
See: https://technet.microsoft.com/en-us/library/mt651674.aspx?f=255&MSPPError=-2147217396
Upvotes: 7
Reputation: 3029
I figured it out.
Here is a link with more information:
[Win 7] setting the option "Password never expires" for a specific local user
Basically, you'd create a script like so:
$user = [adsi]"WinNT://$env:computername/administrator"
$user.UserFlags.value = $user.UserFlags.value -bor 0x10000
$user.CommitChanges()
And then run it, making sure that you replace 'administrator' with the user in question.
Upvotes: 3