Cross-posted at https://stackoverflow.com/questions/61315818/error-with-powershell-pnp-command-for-new-pnp-site
Running the Windows PowerShell ISE as administrator with Import-Module SharePointPnPPowerShellOnline -verbose
.
I'm connected to the SharePoint online site. Using get-pnptenantsite
works fine.
I issue the following command:
New-PnPSite -Type TeamSite -Title "Aaa aaa" -Alias "aaaa" -Owners "[email protected],[email protected]" -Lcid 5129
It sits for ten minutes, then comes back with the error.
New-PnPSite : OfficeDevPnP.Core.Sites.SiteCollection.CreateAsync: Could not create team site.
At line:1 char:1
+ New-PnPSite -Type TeamSite -Title "Aaa aaa" -Alias "aaaa" -Owners "me ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [New-PnPSite], Exception
+ FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.NewSite
I try with fewer owners and no Lcid.
New-PnPSite -Type TeamSite -Title "Aaa aaa" -Alias "aaaa" -Owners "[email protected]"
It immediately comes back with the error that the group alias exists:
New-PnPSite : {"error":{"code":"-2147024713, Microsoft.SharePoint.SPException","message":"The group alias already exists."}}
At line:1 char:1
+ New-PnPSite -Type TeamSite -Title "Aaa aaa" -Alias "aaaa" -Owners "me ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [New-PnPSite], Exception
+ FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.NewSite
Why does that alias exist? It just told me it couldn't create it.
So I try again with a different alias:
New-PnPSite -Type TeamSite -Title "BBB aaa" -Alias "bbbb" -Owners "[email protected]"
Now I get the error
New-PnPSite : {"error":{"code":"-1, System.Data.Services.Client.DataServiceClientException","message":"{\"odata.error\":{\"code\":\"Request_BadRequest\",\"me
ssage\":{\"lang\":\"en\",\"value\":\"One or more added object references already exist for the following modified properties: 'owners'.\"}}}"}}
At line:1 char:1
+ New-PnPSite -Type TeamSite -Title "BBB aaa" -Alias "bbbb" -Owners "me ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [New-PnPSite], Exception
+ FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.NewSite
What am I doing wrong? Will it be faster to create two dozen sites manually through the admin center?