Microsoft365DSC icon indicating copy to clipboard operation
Microsoft365DSC copied to clipboard

SPOSharingSettings: blank authentication window for SPO extract

Open Kikaider opened this issue 6 years ago • 9 comments

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

I tried extracting 2 SPO components from a GCC O365 tenant with Microsoft Cloud App Security enabled (i.e. .us3.cas.ms appended to domain) and MFA enabled. I get a Microsoft Chromium Edge prompt to select from a list of credentials (I use multiple creds on this machine in different Credge profile). After I select the correct creds, I get a blank browser window titled 'Log in to https://domain.admin.sharepoint.com'. If I 'x' out of the window the script moves to the next SPO component and repeats the authentication prompt and blank window.

image

I tried using cmd line and get the same behavior: $creds = Get-Credential $OrganizationName = ($creds.UserName.Split('@')[1]).Split('.')[0] Export-M365DSCConfiguration -Quiet -GlobalAdminAccount $creds -componentsToExtract @("SPOAccessControlSettings","SPOSharingSettings") -FileName "M365TenantConfig-$($OrganizationName).ps1" -Path "$($rootPath)" -ConfigurationName "$($OrganizationName)Config"

When I extract non-SPO components (e.g. Teams) it works fine.

Verbose logs showing the problem

Contents of 12884-M365DSC-ErrorLog.log are below. I think these errors occur after I dismiss the blank auth window.

[2020/07/14 09:51:08] {NotSpecified} System.NullReferenceException: Object reference not set to an instance of an object. at SharePointPnP.PowerShell.Commands.Base.ConnectOnline.ProcessRecord() at System.Management.Automation.CommandProcessor.ProcessRecord() "MSFT_SPOAccessControlSettings.psm1"

[2020/07/14 09:51:24] {NotSpecified} System.NullReferenceException: Object reference not set to an instance of an object. at SharePointPnP.PowerShell.Commands.Base.ConnectOnline.ProcessRecord() at System.Management.Automation.CommandProcessor.ProcessRecord() "MSFT_SPOSharingSettings.psm1"

Suggested solution to the issue

TBD

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

N/A

The operating system the target node is running

I am running DSC from Windows 10 Pro v1909.

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

v1.20.603.1

Kikaider avatar Jul 14 '20 14:07 Kikaider

Manually editing the config, creating the mof, and trying to apply the config results in this error: image

Kikaider avatar Jul 14 '20 14:07 Kikaider

Thanks for reporting the issue. @desmay can you have a look. Also, @Kikaider, you can't run Start-DSCConfiguration on a MOF that was compiled with an MFA enabled account. By nature, the LCM (DSC engine) doesn't allow for prompts, which defeats the process of MFA. You will need to either compile the .MOF with a non-mfa enabled account, or use an Azure AD Application Service Principal.

NikCharlebois avatar Jul 14 '20 14:07 NikCharlebois

@NikCharlebois I'll need to see if I can get a demo tenant configured with Microsoft Cloud App Security enabled to test. I was able to run a successful test in GCC with MFA no issues.

@Kikaider So to be clear format of account with CAS enabled is [email protected]?

desmay avatar Jul 14 '20 15:07 desmay

The user account is the normal [email protected], but the URl for SPO is https://contoso.sharepoint.com.us3.cas.ms.

If you enter https://contoso.sharepoint.com, it redirects to https://contoso.sharepoint.com.us3.cas.ms with a warning page, dismissible for 30 days, in between. The same suffix applies to all O365 URLs, including Teams.

Kikaider avatar Jul 14 '20 16:07 Kikaider

After I disable the AAD Conditional Access Policy that enables the Microsoft Cloud App Security session control I am able to extract SPO components successfully. image

I don't know if there is a specific CAS policy that is causing this. I don't see any policies specifically for PowerShell.

Kikaider avatar Jul 15 '20 23:07 Kikaider

Issue seems to only affect SPO and even when I can get it to work by bypassing CAS, some SPO components still don't work, including SPOApp, SPOSiteAuditSettings, and SPOSiteGroup.

Kikaider avatar Jul 16 '20 18:07 Kikaider

@Kikaider What happens if you:

1 - Run: $creds = Get-Credential Test-MSCloudLogin -Platform PnP -CloudCredential $creds Get-PnpApp

2 - Run: $creds = Get-Credential Get-SPOAdminUrl -CloudCredential $creds

NikCharlebois avatar Jul 26 '20 12:07 NikCharlebois

I apologize for the delay. A recent change to EndPoint Management at my org means my BYOD device is denied because it is not managed. My managed device is an ARM device and can't use AzureADPreview module due to the x86 v. Amd64 issue.

On my BYOD device, I was prompted for my password again and likely MFA if it had made it that far.

I am trying to come up with a workaround to either the BYOD compliance or the ARM issue.

Kikaider avatar Aug 06 '20 12:08 Kikaider

@Kikaider any updates on this? Thanks

NikCharlebois avatar Oct 01 '20 16:10 NikCharlebois