Your users are connecting to terminal server, so they can use an application, and everything works just fine, until one day, a user can’t connect. You swing into action and find out, that the problem lies on your hard drive, or better yet, lack of it. You ran out of disk space on your terminal server. You check what is taking up most of the disk space, and you see there are dozens and dozens of user profile folders. now, you could go, and delete just the folders, but that results in users getting temp profiles. The other option is, to go to advanced settings of your system, and delete profiles from there, But how do you know which ones to delete?
You could delete just the biggest ones, but the User Profiles dialog does not allow you to make any kind of sorting. The other thing you could do, this being a terminal server, is delete all profiles, but one by one? Who wants to do this. You guessed it, a script.
I wrote a script that does just that. It is available on Technet Gallery, https://gallery.technet.microsoft.com/Delete-Disabled-profiles-06d4e82a.
To be able to run it, you must have administrator privileges on target computer and installed Active Directory module on computer running it.
It only works on Windows Vista/Server 2008 and above, as before that, the WMI class I use, did not exist.
Enjoy it, and save your disk space. 🙂