How can I delete SharePoint Online Profile Pictures programatically?

Jun Ye
New Contributor

Does anyone know if there's a way to delete SharePoint Online Profile Pictures programmatically?


For On Premise SharePoint, I'm managing this via this PowerShell Scripts:


# Convert string $objectSid to byte $byteSID

$sid = New-Object System.Security.Principal.SecurityIdentifier ($objectSid)
$byteSID = New-Object 'byte[]' $sid.BinaryLength
$sid.GetBinaryForm($byteSID, 0)


$site=new-object Microsoft.SharePoint.SPSite("http://onprem.sharepoint.local")

$serviceContext = Get-SPServiceContext $site

$upm = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext)


$Userprofile = $upm.GetUserProfile($byteSID)



These users does not have Exchange Online Mailboxes, so I cannot use Set-UserPhoto

I managed to upload photos using via this method, but I cannot remove the pictures once uploaded:



1 Reply

You can try this pnp powershell script to remove picture URL


Connect-PnPOnline -Url https://<tenantname>-admin.sharepoint.com
set-PnPUserProfileProperty -Account alexw@<tenantname>.onmicrosoft.com -PropertyName "PictureURL" -Value ""

Related Conversations
Teams - Chat History
David Gorman in Microsoft Teams on
8 Replies
Remove MS shifts schedule from a Channel in MS Teams
John Crook in Microsoft Teams on
17 Replies
Move Channels between Teams
HerculesConsen in Microsoft Teams on
13 Replies
Auto-Add new employees
Mathias Koprek in Microsoft Teams on
14 Replies
Configuring more than one account in MS-Teams
Biju_Radhakrishnan in Microsoft Teams on
15 Replies