title: How do I write a script to modify the password expiration values for users on a Windows Server?
body: <p>I need to create several users on Windows 2008 servers and modify the password expiration value to "<em>Never</em>". These will be local (not AD) users. I can create them using "<em>net user</em>", it's modifying the pass expiry that is killing me. If I do a "<em>net user username</em>" it lists the field and its value, but there is no switch (at least not one that the help file references) to modify it, and most of the solutions I saw online suggested installing 3rd party tools, however this solution must be native to Windows (ideally using Powershell). Any help is appreciated.  </p>
  
  <p><strong>UPDATE</strong>  </p>
  
  <p>I said if I figured out how to do this in Powershell I would post it here, and I am a man of my word.</p>
  
  <p><code>Get-WmiObject -Class Win32_UserAccount -Filter "name = 'steve'"  | Set-WmiInstance -Argument @{PasswordExpires = 0}</code></p>
  
  <p>This is a boolean value so if you wanted to set a password to expire just change 0 to 1. This is beautiful to me in its simplicity, and I have tested this method updating other WMI objects and it works every time. </p>