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
Retrieving both SPOSearchManagedProperty and SPOSearchResultSource via Export-M365DSCConfiguration using Service Principal with Thumbprint produces the following error:
System.InvalidOperationException: Current site is not a tenant administration site
at PnP.PowerShell.Commands.Search.GetSearchConfiguration.ExecuteCmdlet() in c:\build\src\Commands\Search\GetSearchConfiguration.cs:line 82
at PnP.PowerShell.Commands.Base.PnPConnectedCmdlet.ProcessRecord() in c:\build\src\Commands\Base\PnPConnectedCmdlet.cs:line 53
"Error during Export:"
at Export-TargetResource, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.904.1\DSCResources\MSFT_SPOSearchResultSource\MSFT_SPOSearchResultSource.psm1: line 616
at Start-M365DSCConfigurationExtract, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.904.1\Modules\M365DSCReverse.psm1: line 682
at Export-M365DSCConfiguration, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.904.1\Modules\M365DSCUtil.psm1: line 1391
at <ScriptBlock>, <No file>: line 1
It looks like DSC is establishing a PnP context to the root site (https://tenant.sharepoint.com) instead of the admin site (https://tenant-admin.sharepoint.com). I tried this directly using the PnP.PowerShell cmdlets with the same app and certificate:
Connect-PnPOnline to the root site, then Get-PnPSearchConfiguration -Scope Subscription result: Current site is not a tenant administration site
Connect-PnPOnline to the tenant admin center, then Get-PnPSearchConfiguration -Scope Subscription result: Successfully retrieved XML
Interestingly, once I manually ran Connect-PnPOnline to the tenant admin site, DSC was able to export the search config without issue for the duration of that session.
Microsoft 365 DSC Version
1.24.904.1
Which workloads are affected
SharePoint Online
The DSC configuration
n/a, this is an export
Verbose logs showing the problem
Export-M365DSCConfiguration-ApplicationID "REDACTED"-TenantId "REDACTED"-CertificateThumbprint "REDACTED"-Path c:\DSC -FileName "POC.ps1"-Components @("SPOSearchManagedProperty","SPOSearchResultSource") -Verbose
VERBOSE: No existing connections to Microsoft Graph
Exporting Microsoft 365 configuration for Components: SPOSearchManagedProperty, SPOSearchResultSource
VERBOSE: Loading module from path 'C:\program files\powershell\7\Modules\PackageManagement\PackageManagement.psm1'.
VERBOSE: Loading module from path 'C:\program files\powershell\7\Modules\PackageManagement\PackageManagement.psd1'.
VERBOSE: Loading 'FormatsToProcess'from path 'C:\program files\powershell\7\Modules\PackageManagement\PackageManagement.format.ps1xml'.
VERBOSE: Loading module from path 'C:\program files\powershell\7\Modules\PackageManagement\PackageManagement.psm1'.
VERBOSE: Exporting cmdlet 'Find-Package'.
VERBOSE: Exporting cmdlet 'Find-PackageProvider'.
VERBOSE: Exporting cmdlet 'Get-Package'.
VERBOSE: Exporting cmdlet 'Get-PackageProvider'.
VERBOSE: Exporting cmdlet 'Get-PackageSource'.
VERBOSE: Exporting cmdlet 'Import-PackageProvider'.
VERBOSE: Exporting cmdlet 'Install-Package'.
VERBOSE: Exporting cmdlet 'Install-PackageProvider'.
VERBOSE: Exporting cmdlet 'Register-PackageSource'.
VERBOSE: Exporting cmdlet 'Save-Package'.
VERBOSE: Exporting cmdlet 'Set-PackageSource'.
VERBOSE: Exporting cmdlet 'Uninstall-Package'.
VERBOSE: Exporting cmdlet 'Unregister-PackageSource'.
VERBOSE: Importing cmdlet 'Find-Package'.
VERBOSE: Importing cmdlet 'Find-PackageProvider'.
VERBOSE: Importing cmdlet 'Get-Package'.
VERBOSE: Importing cmdlet 'Get-PackageProvider'.
VERBOSE: Importing cmdlet 'Get-PackageSource'.
VERBOSE: Importing cmdlet 'Import-PackageProvider'.
VERBOSE: Importing cmdlet 'Install-Package'.
VERBOSE: Importing cmdlet 'Install-PackageProvider'.
VERBOSE: Importing cmdlet 'Register-PackageSource'.
VERBOSE: Importing cmdlet 'Save-Package'.
VERBOSE: Importing cmdlet 'Set-PackageSource'.
VERBOSE: Importing cmdlet 'Uninstall-Package'.
VERBOSE: Importing cmdlet 'Unregister-PackageSource'.
Authentication methods specified:
- Service Principal with Certificate Thumbprint
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.904.1\DSCResources\MSFT_SPOSearchManagedProperty\MSFT_SPOSearchManagedProperty.psm1'.
VERBOSE: Importing function 'Export-TargetResource'.
VERBOSE: Importing function 'Get-TargetResource'.
VERBOSE: Importing function 'Set-TargetResource'.
VERBOSE: Importing function 'Test-TargetResource'.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.904.1\DSCResources\MSFT_SPOSearchResultSource\MSFT_SPOSearchResultSource.psm1'.
VERBOSE: Importing function 'Export-TargetResource'.
VERBOSE: Importing function 'Get-TargetResource'.
VERBOSE: Importing function 'Set-TargetResource'.
VERBOSE: Importing function 'Test-TargetResource'.
VERBOSE: Attempting connection to {MicrosoftGraph} with:
VERBOSE:
Name Value
---------
ApplicationSecret
TenantId REDACTED.onmicrosoft.com
CertificatePath
CertificateThumbprint 10424F490D9EFFF49E06FABC3BD3CA1F8D65C1B7
ApplicationId 7c581d25-d636-4f5e-8e6f-180301699811
VERBOSE: Initializing the Connected To Workloads List.
VERBOSE: ApplicationId, TenantId, CertificateThumbprint were specified. Connecting via Service Principal
Connecting to {PnP}...✅
[1/2] Extracting [SPOSearchManagedProperty] using {CertificateThumbprint}...VERBOSE: Attempting connection to {PnP} with:
VERBOSE:
Name Value
---------
TenantId REDACTED.onmicrosoft.com
CertificateThumbprint 10424F490D9EFFF49E06FABC3BD3CA1F8D65C1B7
ApplicationId 7c581d25-d636-4f5e-8e6f-180301699811
VERBOSE: ApplicationId, TenantId, CertificateThumbprint were specified. Connecting via Service Principal
VERBOSE: Dependencies were not already validated.
VERBOSE: Populating RepositorySourceLocation property for module DSCParser.
VERBOSE: Populating RepositorySourceLocation property for module ExchangeOnlineManagement.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\ExchangeOnlineManagement\3.4.0\netCore\ExchangeOnlineManagement.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Applications.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Authentication.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Beta.DeviceManagement.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Beta.DeviceManagement\2.20.0\Microsoft.Graph.Beta.DeviceManagement.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Beta.Devices.CorporateManagement.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Beta.DeviceManagement.Administration.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Beta.DeviceManagement.Administration\2.20.0\Microsoft.Graph.Beta.DeviceManagement.Administration.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Beta.DeviceManagement.Enrollment.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Beta.DeviceManagement.Enrollment\2.20.0\Microsoft.Graph.Beta.DeviceManagement.Enrollment.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Beta.Identity.DirectoryManagement.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Beta.Identity.Governance.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Beta.Identity.SignIns.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Beta.Reports.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Beta.Reports\2.20.0\Microsoft.Graph.Beta.Reports.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Beta.Teams.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.DeviceManagement.Administration.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.DeviceManagement.Administration\2.20.0\Microsoft.Graph.DeviceManagement.Administration.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Beta.DirectoryObjects.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Beta.DirectoryObjects\2.20.0\Microsoft.Graph.Beta.DirectoryObjects.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Groups.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Planner.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Planner\2.20.0\Microsoft.Graph.Planner.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Sites.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Sites\2.20.0\Microsoft.Graph.Sites.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Users.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Users\2.20.0\Microsoft.Graph.Users.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Users.Actions.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.PowerApps.Administration.PowerShell.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\Microsoft.PowerApps.Administration.PowerShell\2.0.191\Microsoft.PowerApps.Administration.Powershell.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module MicrosoftTeams.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\MicrosoftTeams\6.5.0\MicrosoftTeams.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module MSCloudLoginAssistant.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\MSCloudLoginAssistant\1.1.20\ConnectionProfile.psm1'.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\MSCloudLoginAssistant\1.1.20\Workloads\AzureDevOPS.psm1'.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\MSCloudLoginAssistant\1.1.20\Workloads\ExchangeOnline.psm1'.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\MSCloudLoginAssistant\1.1.20\Workloads\Fabric.psm1'.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\MSCloudLoginAssistant\1.1.20\Workloads\MicrosoftGraph.psm1'.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\MSCloudLoginAssistant\1.1.20\Workloads\Teams.psm1'.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\MSCloudLoginAssistant\1.1.20\Workloads\PnP.psm1'.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\MSCloudLoginAssistant\1.1.20\Workloads\PowerPlatform.psm1'.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\MSCloudLoginAssistant\1.1.20\Workloads\SecurityCompliance.psm1'.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\MSCloudLoginAssistant\1.1.20\Workloads\Tasks.psm1'.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\MSCloudLoginAssistant\1.1.20\Workloads\Teams.psm1'.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\MSCloudLoginAssistant\1.1.20\MSCloudLoginAssistant.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module PnP.PowerShell.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PnP.PowerShell\1.12.0\Core\PnP.PowerShell.dll'.
VERBOSE: The dependency {PSDesiredStateConfiguration} requires Windows PowerShell. Skipping.
VERBOSE: Populating RepositorySourceLocation property for module PSDesiredStateConfiguration.
VERBOSE: Removing the imported "Configuration" function.
VERBOSE: Removing the imported "Disable-DscDebug" function.
VERBOSE: Removing the imported "Enable-DscDebug" function.
VERBOSE: Removing the imported "Get-DscConfiguration" function.
VERBOSE: Removing the imported "Get-DscConfigurationStatus" function.
VERBOSE: Removing the imported "Get-DscLocalConfigurationManager" function.
VERBOSE: Removing the imported "Get-DscResource" function.
VERBOSE: Removing the imported "Invoke-DscResource" function.
VERBOSE: Removing the imported "New-DscChecksum" function.
VERBOSE: Removing the imported "Publish-DscConfiguration" function.
VERBOSE: Removing the imported "Remove-DscConfigurationDocument" function.
VERBOSE: Removing the imported "Restore-DscConfiguration" function.
VERBOSE: Removing the imported "Set-DscLocalConfigurationManager" function.
VERBOSE: Removing the imported "Start-DscConfiguration" function.
VERBOSE: Removing the imported "Stop-DscConfiguration" function.
VERBOSE: Removing the imported "Test-DscConfiguration" function.
VERBOSE: Removing the imported "Update-DscConfiguration" function.
VERBOSE: Removing the imported "gcfg" alias.
VERBOSE: Removing the imported "gcfgs" alias.
VERBOSE: Removing the imported "glcm" alias.
VERBOSE: Removing the imported "pbcfg" alias.
VERBOSE: Removing the imported "rtcfg" alias.
VERBOSE: Removing the imported "sacfg" alias.
VERBOSE: Removing the imported "slcm" alias.
VERBOSE: Removing the imported "tcfg" alias.
VERBOSE: Removing the imported "upcfg" alias.
VERBOSE: Loading module from path 'C:\Program Files\PowerShell\Modules\PSDesiredStateConfiguration\2.0.7\PSDesiredStateConfiguration.psd1'.
VERBOSE: Populating RepositorySourceLocation property for module PSDesiredStateConfiguration.
VERBOSE: Loading module from path 'C:\Program Files\PowerShell\Modules\PSDesiredStateConfiguration\2.0.7\PSDesiredStateConfiguration.psm1'.
VERBOSE: Importing function 'PwshConfiguration'.
VERBOSE: Importing function 'Get-PwshDscResource'.
VERBOSE: Importing function 'Invoke-PwshDscResource'.
VERBOSE: Importing function 'New-PwshDscChecksum'.
VERBOSE: Populating RepositorySourceLocation property for module ReverseDSC.
VERBOSE: Dependencies were all successfully validated.
❌
Error Log created at {file://C:/Source/LutzD/M365/Microsoft 365/5364-M365DSC-ErrorLog.log}
[2/2] Extracting [SPOSearchResultSource] using {CertificateThumbprint}...VERBOSE: Attempting connection to {PnP} with:
VERBOSE:
Name Value
---------
TenantId REDACTED.onmicrosoft.com
CertificateThumbprint 10424F490D9EFFF49E06FABC3BD3CA1F8D65C1B7
ApplicationId 7c581d25-d636-4f5e-8e6f-180301699811
VERBOSE: ApplicationId, TenantId, CertificateThumbprint were specified. Connecting via Service Principal
VERBOSE: Dependencies were already successfully validated.
❌
Error Log created at {file://C:/Source/LutzD/M365/Microsoft 365/5364-M365DSC-ErrorLog.log}
Environment Information + PowerShell Version
OsName : Microsoft Windows Server 2016 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture : 64-bit
WindowsVersion : 1607
WindowsBuildLabEx : 14393.7330.amd64fre.rs1_release.240812-1801
OsLanguage : en-US
OsMuiLanguages : {en-US}
Key : PSVersion
Value : 7.4.2
Name : PSVersion
Key : PSEdition
Value : Core
Name : PSEdition
Key : GitCommitId
Value : 7.4.2
Name : GitCommitId
Key : OS
Value : Microsoft Windows 10.0.14393
Name : OS
Key : Platform
Value : Win32NT
Name : Platform
Key : PSCompatibleVersions
Value : {1.0,2.0,3.0,4.0…}
Name : PSCompatibleVersions
Key : PSRemotingProtocolVersion
Value : 2.3
Name : PSRemotingProtocolVersion
Key : SerializationVersion
Value : 1.1.0.1
Name : SerializationVersion
Key : WSManStackVersion
Value : 3.0
Name : WSManStackVersion
The text was updated successfully, but these errors were encountered:
{WriteError}
System.InvalidOperationException: Current site is not a tenant administration site
at PnP.PowerShell.Commands.Search.GetSearchConfiguration.ExecuteCmdlet() in c:\build\src\Commands\Search\GetSearchConfiguration.cs:line 82
at PnP.PowerShell.Commands.Base.PnPConnectedCmdlet.ProcessRecord() in c:\build\src\Commands\Base\PnPConnectedCmdlet.cs:line 51
"Error during Export:"
at Export-TargetResource, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.25.129.3\DSCResources\MSFT_SPOSearchManagedProperty\MSFT_SPOSearchManagedProperty.psm1: line 930
at Start-M365DSCConfigurationExtract, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.25.129.3\Modules\M365DSCReverse.psm1: line 689
at Export-M365DSCConfiguration, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.25.129.3\Modules\M365DSCUtil.psm1: line 1512
at <ScriptBlock>, C:\temp\file.ps1: line 55
at <ScriptBlock>, <No file>: line 1
TenantId: customer.onmicrosoft.com
Anyone knows the reason for this error message?
Thanks!
Description of the issue
Retrieving both
SPOSearchManagedProperty
andSPOSearchResultSource
viaExport-M365DSCConfiguration
using Service Principal with Thumbprint produces the following error:It looks like DSC is establishing a PnP context to the root site (https://tenant.sharepoint.com) instead of the admin site (https://tenant-admin.sharepoint.com). I tried this directly using the
PnP.PowerShell
cmdlets with the same app and certificate:Connect-PnPOnline
to the root site, thenGet-PnPSearchConfiguration -Scope Subscription
result: Current site is not a tenant administration siteConnect-PnPOnline
to the tenant admin center, thenGet-PnPSearchConfiguration -Scope Subscription
result: Successfully retrieved XMLInterestingly, once I manually ran
Connect-PnPOnline
to the tenant admin site, DSC was able to export the search config without issue for the duration of that session.Microsoft 365 DSC Version
1.24.904.1
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: