Skip to content

Remove-UserInfo

SharePoint Online: Removes user info

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

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

Process {
    try {
        $result = Remove-SPOUserInfo -LoginName $LoginName -Site $Site -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 to remove

URL of the site collection

An interactive directory of PowerShell scripts.