Forum Discussion
taichroth_84
Dec 04, 2020Copper Contributor
Delete local User Profiles bulk
Dear all, i search for a script to delete all local user profiles (except system users like admin) as bulk. we have problems of hard disk space because user profiles are getting bigger and bigger b...
trahojen
Jul 07, 2022Copper Contributor
gastone As of July 7th 2022, both links you provided are broken. There's nothing wrong with referencing links, but if you also provide context, pointers to specific functions, calls or headers involved, your response survives changes elsewhere on the Internet and people can form an educated opinion. Now, as it stands, you have not actually answered the question, and that's a shame, because originally you made an effort to be helpful. Peace brother!
As for the original question, enumerate win32_userprofile with Get-CimInstance, identify the ones you want to delete, and call Remove-CimInstance on them. Adam has written an excellent article on this: https://adamtheautomator.com/powershell-delete-user-profile/
gastone
Sep 09, 2022Brass Contributor
The shame is that Microsoft when change his websites has lost many useful links (Blog articles, technet gallery et al), I hope in July 7th 2024 to found Adam's link.