Forum Discussion
Delete local User Profiles bulk
taichroth_84Powershell should be used for this activity, read the following link
https://powershell.org/forums/topic/delete-user-profiles-except-stafflocal-accounts/
https://gallery.technet.microsoft.com/scriptcenter/How-to-delete-user-d86ffd3c
- trahojenJul 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/
- gastoneSep 09, 2022Brass ContributorThe 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.