Delete Old Accounts (Computer or User) with PowerShell

Over the years I’ve found a lot of VBS and PSh scripts that handle old Windows computer or user accounts, but none of them seem to do it quite right. This script uses LastLogonTimeStamp and PWDLastSet together (but not LastLogon), and it gives the administrator the ability to list, disable, move, and/or delete the old accounts. Perhaps the most useful part of this script is the comment header at the top, which explains all of this.

As with any script from the Internet, read it and test it before you use it in production.

 

Delete Old Accounts with PowerShell

Text-based code:
Delete Old Accounts with PowerShell, text-based code excerpts

 

delete accounts with PowerShell

Tags:

Posted in instructional