Microsoft365DSC icon indicating copy to clipboard operation
Microsoft365DSC copied to clipboard

Teams export error

Open gaborenok opened this issue 1 year ago • 2 comments

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.<b__0>d.MoveNext() --- End of inner exception stack trace --- at System.Threading.Tasks.Task1.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.<b__0>d.MoveNext()<---

"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 , : line 99 at Start-M365DSCConfigurationExtract, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.25.1015.1\Modules\M365DSCReverse.psm1: line 789 at Export-M365DSCConfiguration, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.25.1015.1\Modules\M365DSCUtil.psm1: line 1771 at , : line 7 TenantId: configcobra.onmicrosoft.com

Could anyone please help? This is happening with the newest module.

gaborenok avatar Oct 17 '25 12:10 gaborenok

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.

FabienTschanz avatar Oct 17 '25 14:10 FabienTschanz

Thank you this one got solved, I had duplicated module versions.

gaborenok avatar Oct 20 '25 08:10 gaborenok