Delete local user account using PowerShell Script?

Windows PowerShell is a powerful tool that is developed by Microsoft for purposes of task automation and configuration management. This is based on the .NET framework and it includes a command-line shell and a scripting language. Windows PowerShell is designed especially for system administrators. If you are a windows administrator and if you know PowerShell very well and you can simplify and automate tedious and repetitive tasks by creating scripts and combining multiple commands together. This article will guide you to delete local user account using PowerShell, We already know how to create a local user account using the Control panel, settings, and command Prompt. If you create a local user account and you are decided to delete the Local user account with a single click then you’ll find the steps below.

Delete local user account using PowerShell:

Open PowerShell as admin mode and type the following command and hit enter.

Remove-LocalUser -Name “USER_ACCOUNT_NAME”

Instead of the USER_ACCOUNT_NAME type the User account name which you want to remove.

Open Run command by pressing Windows + R and type lusrmgr.msc and hit enter this command will open the local Users and Groups Console.

Click on Users and get the user name.

Local users and groups Eg: Remove-LocalUser -Name “test” Delete local user account using Powershell

Run the command in the PowerShell this command will remove the Local user account immediately.

Creating PowerShell Script:

Creating a PowerShell script is very easy, before running the script make sure the Execution of Scripts is Disabled or not, if not follow the steps to Unrestrict ExecutionPolicy.

Once done follow the below-mentioned steps to create a script. Open any text editor, like notepad. Copy-paste below mentioned cmdlet

Remove-LocalUser -Name “USER_ACCOUNT_NAME”

Instead of the USER_ACCOUNT_NAME type the User account name which you want to remove. Save the Test file as Delete.ps1 and Run the script file from the saved location.

1 thought on “Delete local user account using PowerShell Script?”

  1. How to delete a local user after a point of time? I want to schedule a task to delete the local user at point time through powershell.

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top