Microsoft365DSC icon indicating copy to clipboard operation
Microsoft365DSC copied to clipboard

Connect-MSCloudLoginPnP : The PnP.PowerShell Azure AD Application has not been granted access for this tenant.

Open hmank opened this issue 5 years ago • 1 comments

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

I am running an export M365DscConfiguration in a local powershell session and fails on the error below when trying to connect to PNP.

Verbose logs showing the problem

I receive this error Connect-MSCloudLoginPnP : The PnP.PowerShell Azure AD Application has not been granted access for this tenant. Please run 'Register-PnPManagementShellAccess' to grant access and try again after.

Suggested solution to the issue

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

# insert configuration here

Export-M365DSCConfiguration -Quiet -GlobalAdminAccount $M365creds -Workloads @( "OD", "PP") -ComponentsToExtract ("O365OrgCustomizationSetting", "O365AdminAuditLogConfig", "AADConditionalAccessPolicy", "AADGroupsNamingPolicy", "AADGroupsSettings","AADMSGroupLifecyclePolicy", "AADPolicy", "AADTenantDetails", "EXOAntiPhishPolicy", "EXOAntiPhishRule", "EXOAtpPolicyForO365", "EXODkimSigningConfig", "EXOHostedConnectionFilterPolicy", "EXOHostedContentFilterPolicy", "EXOHostedContentFilterRule", "EXOHostedOutboundSpamFilterPolicy", "EXOMalwareFilterPolicy", "EXOMalwareFilterRule", "EXOSafeAttachmentPolicy", "EXOSafeAttachmentRule", "EXOSafeLinksPolicy", "EXOSafeLinksRule", "EXOSharingPolicy", "SCLabelPolicy", "SCSensitivityLabel", "SCDeviceConditionalAccessPolicy", "SCAuditConfigurationPolicy", "SPOAccessControlSettings", "SPOTenantSettings", "SPOSharingSettings", "SPOTenantCDNEnabled", "SPOTenantCDNPolicy", "TeamsCallingPolicy", "TeamsClientConfiguration", "TeamsGuestCallingConfiguration", "TeamsGuestMeetingConfiguration", "TeamsGuestMessagingConfiguration", "TeamsMeetingBroadcastConfiguration", "TeamsMeetingBroadcastPolicy", "TeamsMeetingConfiguration", "TeamsMeetingPolicy", "TeamsMessagingPolicy", "TeamsUpgradeConfiguration", "TeamsUpgradePolicy" ) -path $path -filename "$Tenantid-$date.ps1" -Verbose

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.21.120.1 Microsoft365DSC

hmank avatar Jan 21 '21 20:01 hmank

@hmank Please review this article on how grant permissions with new PNP Core https://dev.to/svarukala/introducing-the-new-pnp-powershell-based-on-net-core-3-1-and-learn-how-it-s-authentication-works-pn7

desmay avatar Jan 28 '21 12:01 desmay