
To do the same thing from the desktop, go Charms Bar -> Settings -> Control Panel -> Users Accounts and Family Safety -> User Accounts -> Make changes to my account in PC settings, which will bring up the same menu as the previous method. Then just enter the appropriate information and follow the on-screen directions. If you're an administrator and want to add a user, you can from the Start Screen by going to Charms Bar -> Settings -> Change PC Settings -> Users -> Add a User. You can run this PowerShell script using a GPO at shutdown or with a PoSh script in Task Scheduler.Please enable JavaScript to watch this video.

Write-host $LocalProfile.LocalPath, "profile deleted” -ForegroundColor Magenta Gci -force 'C:\Users'-ErrorAction Silentl圜ontinue | ? įoreach ($LocalProfile in $LocalProfiles)

Instead of using the automatic cleanup profile policy described above, you can use a simple PowerShell script to find and remove profiles of disabled or inactive users.įirst of all, let’s try to count the size of all user profil folders in C:\Users using a simple script from the article Getting Directory Sizes in PowerShell: PowerShell Script to Delete Old User Profiles in Windows Also, this policy may not work if some third-party software (most often it is an antivirus) accesses NTUSER.DAT file in user profiles and updates the date of last use. The main troubles associated with this automatic method of profile removal is waiting for the server restart and non-selectivity (you cannot prohibit deleting certain user profiles like local accounts, administrative accounts, etc.).


Otherwise active user profiles may be deleted. When using this policy, make sure that when a server is shut down or restarted there are no problems with the system time (check the article “ System time and date changes after reboot”).
