Error:Microsoft.SharePoint.Client.ServerException: Argument SiteUrl must be a tenant administration

Copper Contributor

Hello- I ma using PNP site provisioning engine to create sites. But while running the batch and at the time of creation of site it is giving error:

"Microsoft.SharePoint.Client.ServerException: Argument SiteUrl must be a tenant administration site."

While I have used Poershell to make the site collection as tenant administration site. Also the apps are having Full Control permission in the site.

Any help will be much appreaciated.

6 Replies

Did you connect / authenticate to the SharePoint Admin Center site (https://[tenantname]-admin.sharepoint.com before executing your PowerShell script? Typically, before executing your PowerShell script to create sites (site collections), you'd first have to connect to SharePoint Online using one of the Connect-SPOService / Connect-SPOnline / Connect-PnPOnline PowerShell commands and specify your SharePoint Admin Center site with a least SharePoint Administrator credentials

I am creating a batch file for on Premises SP 2013.

Hi- I have run below 2 Powershell command:

 

Script1:

cls
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
{
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
$url ="https://SSSSSSSSSSSSSSSSSSSSSS"

Write-Host "Setting $url as tenant site ..." -ForegroundColor Yellow

$site = get-spsite -Identity $url
$site.AdministrationSiteType = [Microsoft.SharePoint.SPAdministrationSiteType]::TenantAdministration 
Write-Host "$url set as tenant site!" -ForegroundColor Green

 

Script2:

Set-SPSiteAdministration "https:/sssssss" -AdministrationSiteType TenantAdministration

IISRESET

Hi @Sayan DuttaMajumdar,

 

This script isn't using the PnP PowerrShell options available.

 

Please look here: https://github.com/SharePoint/PnP-PowerShell/blob/master/Documentation/readme.md

 

 

You are looking for the  New-PnPTenantSite Cmdlet.

 

https://github.com/SharePoint/PnP-PowerShell/blob/master/Documentation/NewPnPTenantSite.md

 

 

 

Hi: Since I am using on Premises: Below 2 PS commands I have used.

Script1:

#

# Enable the remote site collection creation for on-prem in web application level

# If this is not done, unknon object exception is raised by the CSOM code

#

$WebApplicationUrl = http://dev.contoso.com

$snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}

if ($snapin -eq $null) 

{

    Write-Host "Loading SharePoint Powershell Snapin"

    Add-PSSnapin "Microsoft.SharePoint.Powershell"

}    

 

$webapp=Get-SPWebApplication $WebApplicationUrl

$newProxyLibrary = New-Object "Microsoft.SharePoint.Administration.SPClientCallableProxyLibrary"

$newProxyLibrary.AssemblyName = "Microsoft.Online.SharePoint.Dedicated.TenantAdmin.ServerStub, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"

$newProxyLibrary.SupportAppAuthentication = $true

$webapp.ClientCallableSettings.ProxyLibraries.Add($newProxyLibrary)

$webapp.Update()

Write-Host "Successfully added TenantAdmin ServerStub to ClientCallableProxyLibrary."

# Reset the memory of the web application

Write-Host "IISReset..."    

Restart-Service W3SVC,WAS -force

Write-Host "IISReset complete on this server, remember other servers in farm as well."    

 Script2:

 

#

# Set admin site type property to the site collection using PS for any site collection type.

# This is needed to be set for the site collection which is used as the 

# "Connection point" for the CSOM when site collections are created in on-prem

#

$siteColUrl = http://dev.contoso.com

 

$snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}

if ($snapin -eq $null) 

{

    Write-Host "Loading SharePoint Powershell Snapin"

    Add-PSSnapin "Microsoft.SharePoint.Powershell"

}

 

$site = get-spsite -Identity $siteColUrl

$site.AdministrationSiteType = [Microsoft.SharePoint.SPAdministrationSiteType]::TenantAdministration

 

Still getting error after running the batch file..

 

[Error] Error during stage "SiteCreation" siteprovisioning: "https://SSSS"
Microsoft.SharePoint.Client.ServerException: Argument SiteUrl must be a tenant administration site.