You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have installed the latest version of Microsoft365DSC (version 1.25.219.2, February 22, 2025). Additionally, I have an Entra ID App Registration with the necessary SharePoint and Graph claims, made using the "Register-PnPAzureADApp -Interactive" cmdlet. The App Registration is added to the Certificate Store of the Windows computer. When I run the command:
I get the error "The current connection holds no SharePoint context".
Note: I also tried using a manually created App Registration with all claims. Additionally, I ran the script from two different computers, both running Windows 11 with admin rights and the latest Microsoft365DSC module.
Note: I also tried using different SharePoint components, such as "SPOAccessControlSettings", "SPOBrowserIdleSignout", "SPOHomeSite", "SPOTenantCdnPolicy", and "SPOTenantSettings", which are related to the admin site collection of SharePoint, not to a specific site collection, with the same result.
Note: Using PowerShell version 5, NOT 7.x.
Microsoft 365 DSC Version
1.25.219.2
Which workloads are affected
SharePoint Online
The DSC configuration
Verbose logs showing the problem
PS C:\Users\xxxx>Export-M365DSCConfiguration-ApplicationId "xxxx"-TenantId "mytenant.onmicrosoft.com"-CertificateThumbprint "xxxx"-Components @("SPOSite") -ConfigurationName "MyConfig"-Path "C:\Temporary\DSC"-FileName "MyConfig.ps1"-GenerateInfo $true-Verbose
VERBOSE: No existing connections to Microsoft Graph
Exporting Microsoft 365 configuration for Components: SPOSite
Authentication methods specified:
- Service Principal with Certificate Thumbprint
VERBOSE: Removing the imported "Test-TargetResource" function.
VERBOSE: Removing the imported "Set-TargetResource" function.
VERBOSE: Removing the imported "Get-TargetResource" function.
VERBOSE: Removing the imported "Export-TargetResource" function.
VERBOSE: Loading module from path 'C:\ProgramFiles\WindowsPowerShell\Modules\Microsoft365DSC\1.25.219.2\DSCResources\MSFT_SPOSite\MSFT_SPOSite.psm1'.
VERBOSE: Importing function 'Export-TargetResource'.
VERBOSE: Importing function 'Get-TargetResource'.
VERBOSE: Importing function 'Set-TargetResource'.
VERBOSE: Importing function 'Test-TargetResource'.
Connecting to {PnP}...✅
[1/1] Extracting [SPOSite] using {CertificateThumbprint}...VERBOSE: Attempting connection to {PnP} with:
VERBOSE:
Name Value
---------
CertificateThumbprint xxxx
TenantId mytenant.onmicrosoft.com
ApplicationId xxxx
VERBOSE: ApplicationId, TenantId, CertificateThumbprint were specified. Connecting via Service Principal
VERBOSE: Calling into Connect-M365Tenant
VERBOSE: Connection initiated.
VERBOSE: Dependencies were already successfully validated.
❌
Error Log created at {file://C:/Users/xxxx/6132-M365DSC-ErrorLog.log}
⌛ Export took {1 seconds} for {0 instances}
-----------------------------------------------------------------------------------
ErrorLog.log:
[2025/02/2312:05:52]
{NotSpecified}
System.InvalidOperationException: The current connection holds no SharePoint context. Please use one of the Connect-PnPOnline commands which uses the -Url argument to connect.
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()
"Error during Export:"
at Export-TargetResource, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.25.219.2\DSCResources\MSFT_SPOSite\MSFT_SPOSite.psm1: line 930
at Start-M365DSCConfigurationExtract, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.25.219.2\Modules\M365DSCReverse.psm1: line 689
at Export-M365DSCConfiguration, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.25.219.2\Modules\M365DSCUtil.psm1: line 1512
at <ScriptBlock>,<No file>: line 1
TenantId: mydomain.onmicrosoft.com
Environment Information + PowerShell Version
OsName : Microsoft Windows 11 Pro N
OsOperatingSystemSKU : 49
OsArchitecture : 64-bit
WindowsVersion : 2009
WindowsBuildLabEx : 22000.1.amd64fre.co_release.210604-1628
OsLanguage : en-US
OsMuiLanguages : {en-US}
PowerShell version:
Major Minor Build Revision
-----------------------51220002538
The text was updated successfully, but these errors were encountered:
Description of the issue
I have installed the latest version of Microsoft365DSC (version 1.25.219.2, February 22, 2025). Additionally, I have an Entra ID App Registration with the necessary SharePoint and Graph claims, made using the "Register-PnPAzureADApp -Interactive" cmdlet. The App Registration is added to the Certificate Store of the Windows computer. When I run the command:
Export-M365DSCConfiguration -ApplicationId "xxxx-xxxx-xxxx-xxxx-xxxx" -TenantId "mydomain.onmicrosoft.com" -CertificateThumbprint "xxxxx" -Components @("SPOSite") -ConfigurationName "MyConfig" -Path "C:\Temporary\DSC" -FileName "MyConfig.ps1" -GenerateInfo $true
I get the error "The current connection holds no SharePoint context".
Note: I also tried using a manually created App Registration with all claims. Additionally, I ran the script from two different computers, both running Windows 11 with admin rights and the latest Microsoft365DSC module.
Note: I also tried using different SharePoint components, such as "SPOAccessControlSettings", "SPOBrowserIdleSignout", "SPOHomeSite", "SPOTenantCdnPolicy", and "SPOTenantSettings", which are related to the admin site collection of SharePoint, not to a specific site collection, with the same result.
Note: Using PowerShell version 5, NOT 7.x.
Microsoft 365 DSC Version
1.25.219.2
Which workloads are affected
SharePoint Online
The DSC configuration
Verbose logs showing the problem
Environment Information + PowerShell Version
The text was updated successfully, but these errors were encountered: