pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
987 stars 665 forks source link

[BUG] Connect-PnPOnline to a site collection using user credentials fails with the error "Current site is not a tenant administration site" #2917

Open okms opened 3 years ago

okms commented 3 years ago

Expected behavior

Using Connect-PnPOnline with regular user credentials should allow a connection to a regular site

Actual behavior

Using Connect-PnPOnline with regular user credentials should does not allow a connection to a regular site, only to the tenant admin site

Steps to reproduce behavior

Please include complete code samples in-line or linked from gists

  1. Create a plain old site collection
  2. Connect to site collection (note i have stored a generic credential with the label okms in credential manager).

Note: as far as i can tell this issue is not there in they May 2020 release

PowerShell> New-PnPTenantSite -Title "DSS FIN Migration list" -Url /sites/dss-fin-migration -Description "" -Owner admin@okms.onmicrosoft.com -Lcid 1044 -Template STS#0 -TimeZone 6
WARNING: Parameter 'Description' is obsolete. This parameter is currently ignored due to server side API issues when setting this value.

Confirm
Create site with url 'https://okms.sharepoint.com/sites/dss-fin-migration'?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y
................................

PowerShell> Connect-PnPOnline -Url https://okms.sharepoint.com/sites/dss-fin-migration -Credentials okms
powershell.exe Error: 0 : 2020-09-16 10:28:40.4561      [OfficeDevPnP.Core]     [0]     [Error] ExecuteQuery threw following exception: Microsoft.SharePoint.Client.ServerException: Current site is not a tenant administration site.
   at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)
   at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
   at Microsoft.SharePoint.Client.ClientRequest.<ExecuteQueryToServerAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.SharePoint.Client.ClientRequest.<ExecuteQueryAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.SharePoint.Client.ClientRuntimeContext.<ExecuteQueryAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.SharePoint.Client.ClientContext.<ExecuteQueryAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.SharePoint.Client.ClientContextExtensions.<ExecuteQueryImplementation>d__7.MoveNext()
ServerErrorCode: -1
ServerErrorTypeName: Microsoft.Online.SharePoint.Common.SpoException
ServerErrorTraceCorrelationId: 48837a9f-b062-a000-dd19-f1404fff1e5e
ServerErrorValue:
ServerErrorDetails:
.       0ms

Which version of the PnP-PowerShell Cmdlets are you using?

What is the version of the Cmdlet module you are running?

SharePointPnPPowerShellOnline 3.25.2009.1

How did you install the PnP-PowerShell Cmdlets?

cc: @wobba I logged this here as im not sure if this is releated to core.

okms commented 3 years ago

Confirmed that this bug is not present in 3.21.2005.2 image

e-gallis commented 3 years ago

@okms @erwinvanhunen I have the same problem using the Get-PnPProvisioningTemplate. In the log file it says: Current site is not a tenant administration site. It's strange because I'm just connecting to a regular SharePoint site. This is really blocking me in my work as I cannot extract my SharePoint site anymore. Thanks for you help...

evlo commented 3 years ago

maybe Set-PnPTraceLog Level?

but even so, I have trouble with PnP not seeing all the lists it could have with 3.26.2010.0, after reverting 3.23.2007.1 - I still get the "error" (well, debug message), but it actually connects and I can see all the lists I have permissions for.

hasannaqvi83 commented 3 years ago

I also am getting the same error message.

My SharePointPnPPowerShellOnline version is 3.26.2010.0

vphil6dev commented 3 years ago

I was trying to create a provisioning template from a multiIingual Communication Site containing a page with 2 translated pages, and I also got the same issue (with version 3.26.2020.0). However, while the error message "Current site is not a tenant administration site" appears in the PnPTraceLog, the template is created successfully, including the content of the tag . Applying the template generates the same error in the log, and the main page is successfully provisioned but not the translated pages. After reverting to version 3.21.2005.2, everthing is working fine.