SPOSharingSettings: Unable to extract as global admin
Details of the scenario you tried and the problem that is occurring
I tried to extract only the SPOSharingSettings Configuration from a tenant as global admin. The extraction doesn't work. I receive an empty M365TenantConfig.ps1 file like [...] Node localhost{ } [...]
Verbose logs showing the problem
[1/1] Extracting [SPOSharingSettings]...❌
❌
Error Log created at {C:\Users\XXX\DSCProject\14548-M365DSC-ErrorLog.log}
Content of the log file:
[2021.08.30 05:43:19]
{NotSpecified}
System.Management.Automation.MethodInvocationException: Exception calling "SourceExists" with "1" argument(s): "The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security, State." ---> System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security, State.
at System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly, Boolean wantToCreate)
at System.Diagnostics.EventLog.SourceExists(String source, String machineName, Boolean wantToCreate)
at System.Diagnostics.EventLog.SourceExists(String source)
at CallSite.Target(Closure , CallSite , Type , String )
--- End of inner exception stack trace ---
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
"Could not write to event log Source {MSFT_SPOSharingSettings} EntryType {Error} Message {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.}"
at Add-M365DSCEvent, C:\Users\XXX\Documents\WindowsPowerShell\Modules\Microsoft365DSC\1.21.825.1\modules\M365DSCLogEngine.psm1: line 104
at Export-TargetResource, C:\Users\XXX\Documents\WindowsPowerShell\Modules\Microsoft365DSC\1.21.825.1\DSCResources\MSFT_SPOSharingSettings\MSFT_SPOSharingSettings.psm1: line 728
at Start-M365DSCConfigurationExtract, C:\Users\XXX\Documents\WindowsPowerShell\Modules\Microsoft365DSC\1.21.825.1\modules\M365DSCReverse.psm1: line 517
at Export-M365DSCConfiguration, C:\Users\XXX\Documents\WindowsPowerShell\Modules\Microsoft365DSC\1.21.825.1\modules\M365DSCUtil.psm1: line 912
at
Suggested solution to the issue
N/A
The DSC configuration that is used to reproduce the issue (as detailed as possible)
# Generated by Microsoft365DSC from https://export-preview.microsoft365dsc.com on 8/30/2021, 5:14:05 PM
# Visit https://microsoft365dsc.com for more information
# Getting client credentials
$Credentials = Get-Credential
# Exporting resources using credentials
Export-M365DSCConfiguration -Quiet -ComponentsToExtract @("SPOSharingSettings") -GlobalAdminAccount $Credentials
The operating system the target node is running
OsName : Microsoft Windows 10 Enterprise OsOperatingSystemSKU : EnterpriseEdition OsArchitecture : 64-bit WindowsVersion : 2009 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)
dev
@nightshifty It appears you haven't granted PNP access to your tenant. Please review https://dev.to/svarukala/introducing-the-new-pnp-powershell-based-on-net-core-3-1-and-learn-how-it-s-authentication-works-pn7
@desmay Thanks a lot you for your reply.
So I need to call Register-PnPManagementShellAccess which needs global admin permissions.
I only want to use M365DSC for extraction and assessment.
Do I get the following right?:
If the PNP access is not granted and I don't have admin permissions but I only have global reader permissions this means I will be unable to use all M365DSC SPO ressources which use PNP?
Correct the new PNP core needs to granted permissions to tenant before you can use it even if you just want to extract configurations
@nightshifty has this been fixed for you now? Thanks
@nightshifty Any feedback would be appreciated. You would need to register PnP.PowerShell to be able to successfully export the settings.
Thank you for your feedback. Unfortunately I don't have admin permissions on the tenant so I decided to use a different approach than using M365DSC for my use case.