Get or set local user account expiration date - PowerShell
In this post, I describe how to get or set the local user account expiry date in PowerShell.
Resolution
To get the current account expires date, run the following command in PowerShell, replacing accountname with the account you want to get.
Get-LocalUser accountname|SELECT *
To set the expiry date to a specified date:
Set-LocalUser asmith -AccountExpires (Get-Date).AddDays(12)
To set the expiry date to never expire:
Set-LocalUser accountname -AccountNeverExpires
Comments
Post a Comment