# Note: this script came from https://adamtheautomator.com/powershell-delete-user-profile/ $UserToDelete = '{[UserToDelete]}' Get-CimInstance -Class Win32_UserProfile | Where-Object { $_.LocalPath.split('\')[-1] -eq "${UserToDelete}" } | Remove-CimInstance