<#
******-------------------------------------------------------------------------------------------------******
Author -> Shiv Mangal Singh
Date -> 12 th March - 2017
Description -> Add and Remove Site Collection Administrator across Tenant through Powershell.
******-------------------------------------------------------------------------------------------------******
#>
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
$Credential = Get-Credential
#Variables for processing
$AdminURL = "https://Office365.contoso.com/"
$loginName ="shivsingh@contoso.com"
#Connect to SharePoint Online
Connect-SPOService -Url $AdminURL -Credential $Credential
# Get All Site Collection Name
$Sitecolls = Get-SPOSite -Limit All
foreach($Site in $Sitecolls)
{
Write-Host "Adding Site Collection Administrator for Site:" $Site.url
#Add Site collection Admin
Set-SPOUser -Site $Site -LoginName $loginName -IsSiteCollectionAdmin $True
# Remove Site Collection admin
# Set-SPOUser -Site $Site -LoginName $loginName -IsSiteCollectionAdmin $False
}
# Disconnect to SharePoint Online
Disconnect-SPOService
******-------------------------------------------------------------------------------------------------******
Author -> Shiv Mangal Singh
Date -> 12 th March - 2017
Description -> Add and Remove Site Collection Administrator across Tenant through Powershell.
******-------------------------------------------------------------------------------------------------******
#>
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
$Credential = Get-Credential
#Variables for processing
$AdminURL = "https://Office365.contoso.com/"
$loginName ="shivsingh@contoso.com"
#Connect to SharePoint Online
Connect-SPOService -Url $AdminURL -Credential $Credential
# Get All Site Collection Name
$Sitecolls = Get-SPOSite -Limit All
foreach($Site in $Sitecolls)
{
Write-Host "Adding Site Collection Administrator for Site:" $Site.url
#Add Site collection Admin
Set-SPOUser -Site $Site -LoginName $loginName -IsSiteCollectionAdmin $True
# Remove Site Collection admin
# Set-SPOUser -Site $Site -LoginName $loginName -IsSiteCollectionAdmin $False
}
# Disconnect to SharePoint Online
Disconnect-SPOService
No comments:
Post a Comment