I’ve been trying to work on a script that will remove any user profiles that are older than 30 days on some of the computers in my organization. I want the script to run the same as going to Control Panel > System > Advanced System Settings > User Profiles and deleting them from there. I’m pretty new to PowerShell, so don’t rip on me too hard lol. Here is what I have so far, but it’s not working. Any suggestions?
I clean up roaming profiles with this script (you can leave out the “roaming” part of course but if you do be careful not to delete the default or admin profiles):