<#
******------------------------------------------------------------------------------------------------------------------------------******
Author -> Shiv Mangal Singh
Date -> 12 th March - 2017
Description -> Add and Remove Site Collection Administrator in SharePoint Online through Powershell.
******------------------------------------------------------------------------------------------------------------------------------******
#>
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
$Credential = Get-Credential
#Variables for processing
$AdminURL = "https://office365.connect.contoso/"
$loginName ="abc@contoso.com"
#Connect to SharePoint Online
Connect-SPOService -Url $AdminURL -Credential $Credential
# Get All Site Collection from SiteColl.txt file
$Sitecolls = Get-Content "D:\shiv\SubsiteFullControlReport\SiteColl.txt"
Write-Host $Sitecolls
foreach($Site in $Sitecolls)
{
Write-Host "Adding Site Collection Administrator for Site:" $Site
#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 in SharePoint Online through Powershell.
******------------------------------------------------------------------------------------------------------------------------------******
#>
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
$Credential = Get-Credential
#Variables for processing
$AdminURL = "https://office365.connect.contoso/"
$loginName ="abc@contoso.com"
#Connect to SharePoint Online
Connect-SPOService -Url $AdminURL -Credential $Credential
# Get All Site Collection from SiteColl.txt file
$Sitecolls = Get-Content "D:\shiv\SubsiteFullControlReport\SiteColl.txt"
Write-Host $Sitecolls
foreach($Site in $Sitecolls)
{
Write-Host "Adding Site Collection Administrator for Site:" $Site
#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