• Home
  • About 404TS
  • Contact

404 Tech Support

Where IT Help is Found

  • Articles
    • Code
    • Entertainment
    • Going Green
    • Hardware, Gadgets, and Products
    • Management
    • Network
    • News
    • Operating Systems
    • Security and Privacy
    • Software
    • System Administration
    • Talking Points
    • Tech Solutions
    • Web
    • Webmaster
  • Reviews
  • Media
    • Infographics
    • Videos
  • Tech Events
  • Tools
    • How do I find my IP address?
    • Browser and plugin tests
  • Get a Technical Consultation
You are here: Home / Articles / Code / PowerShell script to remove user profiles

PowerShell script to remove user profiles

2016-02-18 by Jason

Removing Windows profiles can be a little tricky. You cannot just delete the files under C:\Users or else the account will have problems logging in the next time with entries still in the registry.

The proper way to remove a profile manually in Windows is to go to System, click Advanced system settings, and under the Advanced tab of the System Properties window choose Settings under User Profiles. Find the profile you wish to remove and select delete. This will cleanly delete its files and registry entries. If you are having logon issues, you might back up that profile’s data and delete the profile with the previous method. Next time you login, the profile will start from the default profile and you can copy your data back to where it goes.

To script the process, you have similar problems in that you can’t just delete the files. Instead, we will have Windows functions do the removal for us. This PowerShell script will query for all Windows profiles and then it excludes Special profiles (like Default), the local Administrator, and other profiles. All other profiles will be deleted. I assigned this as a shutdown script so every shutdown or restart, all profiles are deleted.

https://gist.github.com/jhamilton09/d33569e6209ad36c9606

You will note that I had to exclude the UpdatusUser in my case as well. It was causing the script to error out because some files were in use and could not be removed. UpdatusUser is an account created by NVIDIA drivers with annoying side effects like this.

Filed Under: Code Tagged With: powershell

Trending

  • Resource conflict thanks to ATI PCI Express 3GIO Filter Driver
    In Tech Solutions
  • What Your Browser Says About You and Security Tips
    In Media, Security and Privacy
  • 3 Key Features of Pets Health Monitoring Systems
    In Articles, Hardware, Gadgets, and Products

Latest Media Posts

Find Out Where To Download SNES ROMs

Find Out Where To Download SNES ROMs

Multifunctional Video Conversion Tools – Wondershare Video Converter

Multifunctional Video Conversion Tools – Wondershare Video Converter

  • Popular
  • Latest
  • Today Week Month All
  • Access to the resource [servershare] has been disallowed Access to the resource [servershare] has been disallowed
  • Read the Event Logs on Windows Server Core Read the Event Logs on Windows Server Core
  • What is the AllJoyn Router Service on Windows 10? What is the AllJoyn Router Service on Windows 10?
  • Increase IIS Private Memory Limit to improve WSUS availability Increase IIS Private Memory Limit to improve WSUS availability
  • SOLVED: “This modification is not allowed because the selection is locked.” SOLVED: "This modification is not allowed because the selection is locked."
  • How Virtual Reality Supports Mental Health Therapy How Virtual Reality Supports Mental Health Therapy
  • Key Strategies of Successful Coin Listing on Exchange Key Strategies of Successful Coin Listing on Exchange
  • Keeping Your Mac Healthy: A Comprehensive Guide to Maintenance and Troubleshooting Keeping Your Mac Healthy: A Comprehensive Guide to Maintenance and Troubleshooting
  • Making Distributed Software Development Work: Strategies and Best Practices for Managing Remote Teams Making Distributed Software Development Work: Strategies and Best Practices for Managing Remote Teams
  • customer contactless payment for drink with mobile phon at cafe counter bar,seller coffee shop accept payment by mobile.new normal lifestyle concept The Latest Innovations In Payment Technology
Ajax spinner

Elevator Pitch

404 Tech Support documents solutions to IT problems, shares worthwhile software and websites, and reviews hardware, consumer electronics, and technology-related books.

Subscribe to 404TS articles by email.

Recent Posts

  • How Virtual Reality Supports Mental Health Therapy
  • Key Strategies of Successful Coin Listing on Exchange
  • Keeping Your Mac Healthy: A Comprehensive Guide to Maintenance and Troubleshooting

Search

FTC Disclaimer

404TechSupport is an Amazon.com affiliate; when you click on an Amazon link from 404TS, the site gets a cut of the proceeds from whatever you buy. This site also uses Skimlinks for smart monetization of other affiliate links.
Use of this site requires displaying and viewing ads as they are presented.

Copyright © 2025 · Magazine Pro Theme on Genesis Framework · WordPress · Log in