Microsoft365DSC icon indicating copy to clipboard operation
Microsoft365DSC copied to clipboard

System.InvalidOperationException: There is currently no connection yet. Use Connect-PnPOnline to connect.

Open hmank opened this issue 6 years ago • 10 comments

Details of the scenario you tried and the problem that is occurring

I have removed my DSC powershell modules, and reinstalled. I ran Export-M365DSCConfiguration and be began the export and threw an error.

If I Connect-PNPOnline and re-run the export it runs successfully.

Verbose logs showing the problem

Suggested solution to the issue

[2020/09/09 04:38:07] {NotSpecified} System.InvalidOperationException: There is currently no connection yet. Use Connect-PnPOnline to connect. at PnP.PowerShell.Commands.Base.PnPConnectedCmdlet.BeginProcessing() at PnP.PowerShell.Commands.PnPSharePointCmdlet.BeginProcessing() at PnP.PowerShell.Commands.Base.PnPAdminCmdlet.BeginProcessing() at System.Management.Automation.Cmdlet.DoBeginProcessing() at System.Management.Automation.CommandProcessorBase.DoBegin() "Failed to get Tenant client sync settings"

[2020/09/09 04:38:41] {NotSpecified} System.InvalidOperationException: There is currently no connection yet. Use Connect-PnPOnline to connect. at PnP.PowerShell.Commands.Base.PnPConnectedCmdlet.BeginProcessing() at PnP.PowerShell.Commands.PnPSharePointCmdlet.BeginProcessing() at PnP.PowerShell.Commands.PnPWebCmdlet.BeginProcessing() at System.Management.Automation.Cmdlet.DoBeginProcessing() at System.Management.Automation.CommandProcessorBase.DoBegin() ""

The DSC configuration that is used to reproduce the issue (as detailed as possible)

# insert configuration here

The operating system the target node is running

OsName : Microsoft Windows 10 Pro OsOperatingSystemSKU : 48 OsArchitecture : 64-bit WindowsVersion : 2004 WindowsBuildLabEx : 19041.1.amd64fre.vb_release.191206-1406 OsLanguage : en-US OsMuiLanguages : {en-US}

Version of the DSC module that was used ('dev' if using current dev branch)

1.20.909.1

hmank avatar Sep 09 '20 21:09 hmank

@hmank What if you actually try to connect (in a new PoSh session) using the MSCloudLoginAssistant, does that work?

Test-MSCloudLoginAssistant -Platform PnP

Adding @desmay for visibility

NikCharlebois avatar Sep 09 '20 21:09 NikCharlebois

Tested and it throws an error >> TerminatingError(Connect-PnPOnline): "Cannot contact web site 'https://m365xTEST-admin.sharepoint.com/' or the web site does not support SharePoint Online credentials. The response status code is 'Unauthorized'. The response headers are 'X-SharePointHealthScore=0, X-MSDAVEXT_Error=917656; Access+denied.+Before+opening+files+in+this+location%2c+you+must+first+browse+to+the+web+site+and+select+the+option+to+login+automatically., SPRequestGuid=3078789f-a01b-b000-08fb-d407a4a7e958, request-id=3078789f-a01b-b000-08fb-d407a4a7e958, MS-CV=n3h4MBugALAI+9QHpKfpWA.0, Strict-Transport-Security=max-age=31536000, SPRequestDuration=13, SPIisLatency=0, MicrosoftSharePointTeamServices=16.0.0.20426, X-Content-Type-Options=nosniff, X-MS-InvokeApp=1; RequireReadOnly, Content-Length=0, Content-Type=text/plain; charset=utf-8, Date=Thu, 10 Sep 2020 00:06:54 GMT, P3P=CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI", Server=Microsoft-IIS/10.0, X-Powered-By=ASP.NET'." PS C:\temp> stop-transcript Test-MSCloudLogin.txt

hmank avatar Sep 10 '20 00:09 hmank

@hmank Thanks, slowly going doing to the lower levels of authentication logic, can you try:

Connect-PnPOnline -Url 'https://m365xTEST-admin.sharepoint.com/'

what's the result?

NikCharlebois avatar Sep 11 '20 12:09 NikCharlebois

Yep, if I run the cmdlet manually I am able to connect, I can then re-run the Export-M365DscConfiguration successfully. However If i try and run the export before connecting to pnp-online it will fail with the error above.

hmank avatar Sep 11 '20 15:09 hmank

I am seeing the same issue.

DeanGross avatar Sep 12 '20 19:09 DeanGross

@desmay any thoughts here?

NikCharlebois avatar Oct 27 '20 16:10 NikCharlebois

@hmank or @DeanGross are you authenticating using an *.onmicrosoft.com account ?

desmay avatar Oct 27 '20 16:10 desmay

@hmank or @DeanGross by chance are you using MFA enabled accounts as well?

desmay avatar Oct 29 '20 17:10 desmay

@desmay My account does have MFA enabled, it is not a *.onmicrosoft.com account.

DeanGross avatar Oct 30 '20 12:10 DeanGross

Are you folks able to replicate on latest versions?

NikCharlebois avatar Jul 06 '21 14:07 NikCharlebois