Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Editing a local user

$
0
0

How can I change the check box where it says "Password does not expire" from unchecked to checked with out having to create a new user all over again.

This is what I have so far.

$Computer = [ADSI]"WinNT://$Env:COMPUTERNAME,Computer"
$LocalAdmin = $Computer.Create("User", "Bob")
$LocalAdmin.SetPassword("Passw0rd123")
$LocalAdmin.SetInfo()
$LocalAdmin.FullName = "Bob"
$LocalAdmin.SetInfo()
$LocalAdmin.UserFlags = 65536 # code for Password does not expire
$LocalAdmin.SetInfo()

This code creates a user called Bob and checks the checkbox for "Password does not expire".

What if a user has their check box unchecked, how do I change it so it will be checked? Or vise-versa.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>