Monthly Archive


Setting local account expiry dates

Setting expiry dates on AD accounts is a common occurrence and is well documented. Setting expiry dates on local accounts is also possible

$user = [adsi]"WinNT://./Test1, user"            
$expirydate = (Get-Date).AddDays(2)            
$user.Put("AccountExpirationDate", $expirydate)            
$user | Format-List *

This uses the WinNT (remember its case sensitive) ADSI connector to get a local account.  We then set the AccountExpirationDate property to the desired date – in this case two days from now.

Quick call to SetInfo() and we are done

Leave a Reply