Command
Add-SiteCollectionAdministrator
Description
This command automatically adds site collection administrator rights to your user account when you connect to a site.
Notes:
You can use the Remove-SiteCollectionAdministrator command to remove the permission after your operation.
Your site will be added to Explorer when the connection is made.
Your user account will need to have sufficient permissions to be added as a site collection administrator.
To grant this permission to multiple site collections or OneDrives, you can use a foreach loop or use the application.
Examples
Add Site Collection Administrator rights on site
# Connect to the SharePoint site using the specified URL
$site = Connect-Site -Url "http://myfarm1/sites/mysite"
# Add a Site Collection Administrator to the specified SharePoint site
Add-SiteCollectionAdministrator -Site $site
Add Site Collection Administrator rights on site from the central administration
# Connect to the SharePoint Central Administration site
$centralAdminSite = Connect-Site -Url "http://myfarm1:5000"
# Add a Site Collection Administrator to the specified SharePoint site
Add-SiteCollectionAdministrator -CentralAdmin $centralAdminSite -SiteUrl "http://myfarm1/sites/mysite/"
Add Site Collection Administrator rights on site from a tenant
# Connect to the tenant using the specified domain and browser
$tenant = Connect-Tenant -Domain "mytenant" -Browser
# Add a Site Collection Administrator to the SharePoint site
Add-SiteCollectionAdministrator -CentralAdmin $tenant.Site -SiteUrl "https://mytenant.sharepoint.com/sites/mysite/"
Provision and populate One Drive for Business
# Connect to the SharePoint admin site using browser authentication
$tenant = Connect-Site -Url "https://mytenant-admin.sharepoint.com" -Browser
# Get the OneDrive URL for the specified user, provisioning it if it doesn't exist
$oneDriveUrl = Get-OneDriveUrl -Tenant $tenant -Email "[email protected]" -ProvisionIfRequired
# Add a site collection administrator for the user's OneDrive
Add-SiteCollectionAdministrator -CentralAdmin $tenant.Site -SiteUrl $oneDriveUrl
# Connect to the user's OneDrive using stored credentials
$oneDrive = Connect-Site -Url $oneDriveUrl -UseCredentialsFrom $tenant
# Get the "Documents" list from the OneDrive site
$dstList = Get-List -Name "Documents" -Site $oneDrive
# Import documents from a shared network drive to the OneDrive "Documents" list
Import-Document -SourceFolder "\\mysharedrive\documentsToImport\" -DestinationList $dstList
# Remove the site collection administrator from the user's OneDrive
Remove-SiteCollectionAdministrator -CentralAdmin $tenant.Site -SiteUrl $oneDriveUrl
Syntax
Add-SiteCollectionAdministrator-Site <Site>
Add-SiteCollectionAdministrator-CentralAdmin <Site> -SiteUrl <String>
Parameters
-CentralAdmin <Site>
Specifies the farm or tenant site for the transform.
Required? | True |
Default value | None |
Accept pipeline input? | True (ByValue, ByPropertyName) |
Accept wildcard characters? | False |
Parameter set name | CentralAdmin |
Aliases | None |
-Site <Site>
Specifies the site to transform.
Required? | True |
Default value | None |
Accept pipeline input? | True (ByValue, ByPropertyName) |
Accept wildcard characters? | False |
Parameter set name | (All) |
Aliases | None |
-SiteUrl <String>
Specifies the site to transform.
Required? | True |
Default value | None |
Accept pipeline input? | True (ByValue, ByPropertyName) |
Accept wildcard characters? | False |
Parameter set name | CentralAdmin |
Aliases | None |