Powershell

Use PowerShell to Delete a User Profile (Step-by-Step Guide)

A Windows user profile contains files, folders, configurations, and registry settings. Windows can have a number of users at a time. Sometimes, user profiles can get corrupted and need to be deleted. User profiles can be created and deleted using Windows settings. However, PowerShell can also help delete the user profile. The prerequisite to deleting a user profile is to back up important data stored in it.

This tutorial will observe a procedure to delete a user profile using PowerShell.

How to Use/Utilize PowerShell to Delete a User Profile?

The user profile in Windows can be deleted using PowerShell’s “Remove-LocalUser” cmdlet. Before moving forward, first, get the list of the user profiles on Windows by executing the “Get-LocalUser” cmdlet:

Get-LocalUser

Let’s remove the user profile of “John” by executing the below-stated code:

Remove-LocalUser -Name "John"

According to the above-stated code:

  • First, add the “Remove-LocalUser” cmdlet, specify the “-Name” parameter and then assign the user name to be deleted.
  • The “Remove-LocalUser” cmdlet is specially used to delete the user profile on Windows using PowerShell:

Again, run the “Get-LocalUser” cmdlet to verify whether the user profile was deleted or not:

Get-LocalUser

It can be observed that the user profile “John” is not visible in the above list. It is now confirmed that the user profile has been deleted.

Conclusion

To delete a user profile on Windows using PowerShell, first, add the “Remove-LocalUser” cmdlet. Then, add the “-Name” parameter and assign the user profile name within inverted commas to be deleted. Lastly, run the “Get-LocalUser” cmdlet to verify the deletion of the user profile. This post has discussed a method to remove a user profile/account in Windows.

About the author

Muhammad Farhan

I am a Computer Science graduate and now a technical writer who loves to provide the easiest solutions to the most difficult problems related to Windows, Linux, and Web designing. My love for Computer Science emerges every day because of its ease in our everyday life.