SOLVED: How To Delete a User Profile On a Remote Computer Using PowerShell

We recently had a customers server have several User Profile issues and we were not able to log onto the server. The solution was to delete the user profiles remotely using this simple PowerShell command which was:

  1. as an Administrator
  2. logged into a different server on the same subnet
  3. with a user that was a Domain Administrator (but local admin on the target server would work aswell)


$Computer = "EXCH01" # Replace with your server's name or IP address
$Username = "alan" # Replace with the username of the profile you want to delete

Invoke-Command -ComputerName $Computer -ScriptBlock {
param($Username)
$profile = Get-WmiObject -Class Win32_UserProfile | Where-Object { $_.LocalPath.split('\')[-1] -eq $Username }
$profile | Remove-WmiObject
} -ArgumentList $Username

Published by
Ian Matthews

This website uses cookies.