PowerShell – Delete User Account

email me

# MrNetTek
# eddiejackson.net/blog
# 5/5/2020
# free for public use 
# free to claim as your own

$domain = 'DOMAIN'
$user = 'JDoe'
$userSID = (New-Object Security.Principal.NTAccount($domain, $user)).Translate([Security.Principal.SecurityIdentifier]).Value

Get-WmiObject -ClassName Win32_UserProfile -Filter "SID='$userSID'" |
  ForEach-Object { 
    Write-Host $_.SID
    $_.Delete()
  }