How to remove a site collection administrator in Office 365 using SharePoint Online PnP Powershell?

Hello ShaerPointers,

Below are the piece of power shell code to remove a site collection administrator in Office 365 Using Pnp Powershell.

param(
[Parameter(Mandatory)]
[String]$Url,
[Parameter(Mandatory)]
[String]$UserName
)
Remove-PnPSiteCollectionAdmin -Owners $loginName -Connection (Connect-PnPOnline $siteUrl -Credentials (Get-Credential) -ReturnConnection)
$object = New-Object PSObject
$object | Add-Member “SiteUrl” $Url
$object | Add-Member “LoginName” $UserName
$object| Add-Member “IsSiteAdmin” (Get-SPOUser -Site $siteUrl -LoginName $loginName | select IsSiteAdmin).IsSiteAdmin

Happy SharePointing Folks!!

Leave a Reply

Your email address will not be published. Required fields are marked *