Teams export error
Hello,
I am having an issue while exporting TeamsClientConfiguration and other teams related resources.
Export-M365DSCConfiguration -Components @("TeamsClientConfiguration") -ApplicationId $ApplicationId -CertificateThumbprint $Certhumb -TenantId $TenantId
Error:
[2025/10/17 02:29:27]
{InvalidOperation}
System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: A Windows PowerShell object cannot be created that uses the current runspace because there is no current runspace available. The current runspace might be starting, such as when it is created with an Initial Session State.
at System.Management.Automation.PowerShell.Create(RunspaceMode runspace)
at Microsoft.TeamsCmdlets.PowerShell.Connect.Utilities.PowerShellUtility.GetVersion(CommandInfo cmdlet)
at Microsoft.TeamsCmdlets.PowerShell.Connect.TPMCmdletHostContract.GetModulesInfo(String& configApiPowershellModuleVersion, String& microsoftTeamsModuleVersion)
at Microsoft.Teams.Policy.Administration.Cmdlets.Providers.CmdletHostWrapper.GetModulesInfo(String& configApiPowershellModuleVersion, String& microsoftTeamsModuleVersion)
at Microsoft.Teams.Policy.Administration.Cmdlets.Providers.HttpRequestHelper1.AddUseragentAndCmdletNameHeaders(HttpRequestMessage request, InvocationInfo invocationInfo) at Microsoft.Teams.Policy.Administration.Cmdlets.Providers.HttpRequestHelper1.AddAdditionalHeaders(HttpRequestMessage request, InvocationInfo invocationInfo)
at Microsoft.Teams.Policy.Administration.Cmdlets.Providers.HttpRequestHelper1.<GetAllAsync>d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Teams.Policy.Administration.Cmdlets.Providers.BaseTpmGetCmdlet1.<>c__DisplayClass8_0.<1.GetResultCore(Boolean waitCompletionNotification) at Microsoft.Teams.Policy.Administration.Cmdlets.Providers.BaseTpmGetCmdlet1.ProcessRecord()
---> (Inner Exception #0) System.InvalidOperationException: A Windows PowerShell object cannot be created that uses the current runspace because there is no current runspace available. The current runspace might be starting, such as when it is created with an Initial Session State.
at System.Management.Automation.PowerShell.Create(RunspaceMode runspace)
at Microsoft.TeamsCmdlets.PowerShell.Connect.Utilities.PowerShellUtility.GetVersion(CommandInfo cmdlet)
at Microsoft.TeamsCmdlets.PowerShell.Connect.TPMCmdletHostContract.GetModulesInfo(String& configApiPowershellModuleVersion, String& microsoftTeamsModuleVersion)
at Microsoft.Teams.Policy.Administration.Cmdlets.Providers.CmdletHostWrapper.GetModulesInfo(String& configApiPowershellModuleVersion, String& microsoftTeamsModuleVersion)
at Microsoft.Teams.Policy.Administration.Cmdlets.Providers.HttpRequestHelper1.AddUseragentAndCmdletNameHeaders(HttpRequestMessage request, InvocationInfo invocationInfo) at Microsoft.Teams.Policy.Administration.Cmdlets.Providers.HttpRequestHelper1.AddAdditionalHeaders(HttpRequestMessage request, InvocationInfo invocationInfo)
at Microsoft.Teams.Policy.Administration.Cmdlets.Providers.HttpRequestHelper1.<GetAllAsync>d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Teams.Policy.Administration.Cmdlets.Providers.BaseTpmGetCmdlet1.<>c__DisplayClass8_0.<
"Error retrieving data:"
at Get-TargetResource, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.25.1015.1\DSCResources\MSFT_TeamsClientConfiguration\MSFT_TeamsClientConfiguration.psm1: line 127
at Export-TargetResource, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.25.1015.1\DSCResources\MSFT_TeamsClientConfiguration\MSFT_TeamsClientConfiguration.psm1: line 479
at
Could anyone please help? This is happening with the newest module.
Does this happen only in Windows PowerShell or in PowerShell 7 as well? Can you please check that? Because I'm able to run it in both.
Thank you this one got solved, I had duplicated module versions.