Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
How to delete user profile from local machines?
Solution: Use the Below PowerShell Script:
001
002
003
004
005
006
007
008
009
010
011
012
013
014
$ups = Get-WmiObject -Class Win32_UserProfile
foreach($up in $ups){
$ErrorActionPreference = "SilentlyContinue"
$objectSID = New-Object System.Security.Principal.SecurityIdentifier($up.SID)
$objectuser = $objectSID.Translate([System.Security.Principal.NTAccount])
$profilename = $objectuser.Value.Split("\)[1]
Write-Host "Available profiles are" $profilename
$up.Delete()
Write-Host "$profilename deleted successfully on $env:ComputerName"
}
If in case any account disabled or removed we may get error so I used $ErrorActionPreference to Silently Continue.