Remove-PnPSiteCollectionAdmin

Removes one or more users as site collection administrators from the site collection in the current context

Syntax

Remove-PnPSiteCollectionAdmin
      -Owners <UserPipeBind>
                                   [-Connection <SPOnlineConnection>]

Description

This command allows removing one to many users as site collection administrators from the site collection in the current context. All existing site collection administrators not included in this command will remain site collection administrator.

Examples

------------------EXAMPLE 1------------------

Remove-PnPSiteCollectionAdmin -Owners "user@contoso.onmicrosoft.com"

This will remove user@contoso.onmicrosoft.com as a site collection owner from the site collection in the current context

------------------EXAMPLE 2------------------

Remove-PnPSiteCollectionAdmin -Owners @("user1@contoso.onmicrosoft.com", "user2@contoso.onmicrosoft.com")

This will remove user1@contoso.onmicrosoft.com and user2@contoso.onmicrosoft.com as site collection owners from the site collection in the current context

------------------EXAMPLE 3------------------

Get-PnPUser | ? Title -Like "*Doe" | Remove-PnPSiteCollectionAdmin

This will remove all users with their title ending with "Doe" as site collection owners from the site collection in the current context

------------------EXAMPLE 4------------------

Get-PnPSiteCollectionAdmin | Remove-PnPSiteCollectionAdmin

This will remove all existing site collection administrators from the site collection in the current context

Parameters

-Connection

Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.

Type:SPOnlineConnection
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Owners

Specifies owner(s) to remove as site collection administrators. Can be both users and groups.

Type:UserPipeBind
Position:Named
Accept pipeline input:True
Accept wildcard characters:False