SharePoint Online: Delete User Profile using PowerShell

Requirement: Delete User Profile in SharePoint Online using PowerShell

How to Delete a User Profile in SharePoint Online?
SharePoint Online user profiles gets deleted when a User account is deleted or disabled in Active Directory. To delete user profile in in SharePoint Online, do the following:
  • Sign in to as a Global Admin or SharePoint Online Admin. 
  • In the left pane, under Admin centers, select SharePoint.
  • In the left pane of the classic SharePoint admin center, select user profiles.
  • Go to User profiles > Manage User Profiles > Search for your user
  • Select the user and click on "Delete" link to delete the user profile in SharePoint Online.
    sharepoint online delete user profile powershell

Deleting user profile in CSOM is not implemented so far, as per:

SharePoint Online: Delete User Profile using PowerShell
Open SharePoint Online Management Shell and run the below script to delete a user profile from SharePoint Online.
#Connect to SharePoint Online
Connect-SPOService -Url

#Remove User Profile
Remove-SPOUserProfile -LoginName [email protected]
This PowerShell deletes user profile in SharePoint Online. Make sure the user account is already deleted in Azure Active Directory, prior to remove the user profile. Otherwise, Profile may get created in the next user profile import job! If you want to exclude some users from User profile import (E.g. Service Accounts), set the filter in AD Connect from On-Premises Active directory!

1 comment:

  1. Is there a recycle bin for deleted users. So i can see who's been removed?


Please Login and comment to get your questions answered!

Powered by Blogger.