Skip to content

Remove-UserProfile

SharePoint Online: Removes a user profile

#Requires -Version 5.1
#Requires -Modules Microsoft.Online.SharePoint.PowerShell

[CmdletBinding()]
Param(
    [string]$LoginName
)

Process {
    try {
        $result = Remove-SPOUserProfile -LoginName $LoginName -ErrorAction Stop | Select-Object *
        if ($null -ne $result) { foreach ($item in $result) { $item | Add-Member -NotePropertyName Timestamp -NotePropertyValue (Get-Date -Format "yyyy-MM-dd HH:mm:ss") -PassThru -Force } }
    }
    catch { throw }
}

Login name of the user whose profile is to be deleted

An interactive directory of PowerShell scripts.