A simple solution is to create a batch file that issues the following command:
net accounts /maxpwage:unlimited
However, this will set the maximum age for all accounts on the local computer unlimited, not just the new accounts you created.
If you need a finer level of control (i.e. the ability to set password expiration values ββfor individual users), you will need something more complex. Scripting Guys share an example of VBScript that will change the local user account so that its password does not expire:
Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000 strDomainOrWorkgroup = "Fabrikam" strComputer = "atl-win2k-01" strUser = "KenMeyer" Set objUser = GetObject("WinNT://" & strDomainOrWorkgroup & "/" & _ strComputer & "/" & strUser & ",User") objUserFlags = objUser.Get("UserFlags") objPasswordExpirationFlag = objUserFlags OR ADS_UF_DONT_EXPIRE_PASSWD objUser.Put "userFlags", objPasswordExpirationFlag objUser.SetInfo
It would be easy to change this to work for any user of your choice or even to create a new user.
Finally, here is an example in C # that you should be able to connect to PowerShell. I'm not a PS expert, but given that it uses the .NET Framework, the code above should give you some ideas.
Cody gray
source share