System.InvalidOperationException: There is currently no connection yet. Use Connect-PnPOnline to connect.
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 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
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 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?
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.
I am seeing the same issue.
@desmay any thoughts here?
@hmank or @DeanGross are you authenticating using an *.onmicrosoft.com account ?
@hmank or @DeanGross by chance are you using MFA enabled accounts as well?
@desmay My account does have MFA enabled, it is not a *.onmicrosoft.com account.
Are you folks able to replicate on latest versions?