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)

how to delete a user profile from a remote computer using powershell

$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


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *