I need to delete a user from the PowerShell terminal and I don’t know how to do it.
Well, fear no more, let’s have a quick read on Remove-LocalUser on how to do this.
The command to delete the user is Remove-LocaUser
.
Remove-LocalUser
[-InputObject] <LocalUser[]>
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-LocalUser
[-Name] <String[]>
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-LocalUser
[-SID] <SecurityIdentifier[]>
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Here is an example of deleting a local user called simba
.
PS C:\> Remove-LocalUser -Name "simba"
That’s it. Note that the above command only remove the user account leaving the user’s profile in C:\Users\simba
. To remove the user profile, it’s quite more complicated. I’ll leave it for another day. Here is a reference to how to delete the user profile using PowerShell: Use PowerShell delete a user profile (step-by-step guide).
Reference: