How to Properly Remove a AzureAD User Profile from a Windows computer with CMD or PowerShell?

What is the proper process to remove a AzureAD User Profile from a Windows computer without reimaging or disconnecting the device from Azure AD?

With local & domain user accounts, removal of user profile data is simple, especially using "net user

Deleting the user folder & profile registry key is not a viable solution as this causes the user to have errors signing in should they return to the computer.

What is the correct process for removing user profile data from a Windows computer using CMD or PowerShell without reimaging, disconnecting the device from AzureAD or, preventing future login using the AzureAD account that was removed from the Windows computer?

Hello! My name is Cristiano. I'm an Independent Advisor. I'm glad to help you.

To remove the user profile data, you can use the `Remove-LocalUser` cmdlet along with the UPN (User Principal Name) of the user. Here is an example:

1. Open PowerShell as an administrator.
2. Type the following command to list all local user accounts:
Get-LocalUser

3. Find the account you want to remove and make note of the account name.
4. Type the following command to remove the account:
Remove-LocalUser -Name "*** Email address is removed for privacy ***"

Make sure to replace "*** Email address is removed for privacy ***" with the UPN of the AzureAD user that you want to remove.

After removing the account with `Remove-LocalUser`, run the following command to remove the profile folder:
Remove-Item -Path C:\Users\

Replace `

1 person found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Hello! My name is Cristiano. I'm an Independent Advisor. I'm glad to help you.

To remove the user profile data, you can use the `Remove-LocalUser` cmdlet along with the UPN (User Principal Name) of the user. Here is an example:

1. Open PowerShell as an administrator.
2. Type the following command to list all local user accounts:

Get-LocalUser


3. Find the account you want to remove and make note of the account name.
4. Type the following command to remove the account:

Remove-LocalUser -Name "*** Email address is removed for privacy ***"


Make sure to replace "*** Email address is removed for privacy ***" with the UPN of the AzureAD user that you want to remove.

After removing the account with `Remove-LocalUser`, run the following command to remove the profile folder:

Remove-Item -Path C:\Users\


Replace `

That's great if you are aware of the local AzureAD users on the PC. Is there a way to list any AzureAD profiles that are present?

2 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

In my opinion this is a terrible answer and doesn't address Robert's question. I'm seeking an answer to the same question.

The question concerns removing an AzureAD user profile which by definition is not a local user. When I use "Get-localuser" none of the AzureAD profiles are displayed.

The Windows device in question is Azure AD joined and numerous users have logged in to the device and are utilizing disk space but no longer use the device. The goal is to remove AzureAD profile and any disk space associated with the user, but not prevent the user from logging in again in the future and creating a new profile.

Is there a simple way to accomplish this from powershell?

P.S. I queried ChatAI to answer this question and it responded with

Remove-AzureADUser -objectId "*** Email address is removed for privacy ***"

which goes to show you can't always trust AI as that removes the user from AzureAD not their profile from local device!

I did find that you can accomplish the task manually by entering

"Advance System Settings" in Windows search

Click on Advanced | User Profiles | Settings

From there you can properly delete any AzureAD profiles on the local device.

How to do that from powershell remains the outstanding question.

Also see spiceworks.com article 2336982-how-to-remove-user-s-azure-ad-profile-from-windows-10-pc

for how to set user profiles to automatically expire in X days of inactivity which is perhaps an even better answer.

55 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

I totally agree with you. The answer is TOTALLY inadequate.

10 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated March 26, 2025 Views 16,185 Applies to: