David Williams Technical


Endpoint Management & Deployment – MDM Management – Scripting – Cyber Security Engineering – Application Configuration & Deployment

Remove Users from a PC using PowerShell

This document outlines how to remove users from a computer using PowerShell.

Firstly, run PowerShell as an administrator and type the command:

Get-WMIObject -class Win32_UserProfile | Where {(!$.Special) -and ($.ConvertToDateTime($_.LastUseTime) -lt (Get-Date).AddDays(-180))} | Remove-WmiObject

This will remove the users that are over 180 days old. The parameter AddDays(-180) can be adjusted to any time length if you wish to delete users after a week just adjust the parameter to AddDays(-7).


Alternatively you can use the click method for manual removal of user accounts:

  1. Control Panel
  2. System
  3. Advanced System Settings
  4. Settings on User Profiles
  5. Select profile
  6. Press Delete