can not import Teams PowerShell module in .net core 3.1

%3CLINGO-SUB%20id%3D%22lingo-sub-2880171%22%20slang%3D%22en-US%22%3Ecan%20not%20import%20Teams%20PowerShell%20module%20in%20.net%20core%203.1%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2880171%22%20slang%3D%22en-US%22%3E%3CP%3EI%20tried%20to%20import%20the%20teams%20powershell%20module%20in%20.net%20core%203.1%2C%20windows%20server%202012r2%2C%20and%20the%20Microsoft.PowerShell.SDK%20version%20is%207.0.8.%20I%20can%20get%20the%20module%20via%20Test-ModuleManifest%2C%20but%20the%20teams%20module%20can't%20be%20imported%2C%20there%20is%20no%20any%20errors%2C%20I%20have%20tried%20some%20different%20teams%20PS%20gallery%20version%20like%202.3.1%2C%202.6.0.%20I%20can%20import%20the%20teams%20module%20in%20powershell%20desktop%20in%20the%20same%20windows%20environment.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3EPSModuleInfo%20teamsModule%20%3D%20null%3B%0Ausing%20(Pipeline%20pipeLine%20%3D%20runspace.CreatePipeline())%0A%7B%0ACommand%20command%20%3D%20new%20Command(%22Test-ModuleManifest%22)%3B%0A%2F%2Fcommand.Parameters.Add(%22Path%22%2C%20%40%22C%3A%5CProgram%20Files%5CWindowsPowerShell%5CModules%5CMicrosoftTeams%5C2.6.0%5CMicrosoftTeams.psd1%22)%3B%0Acommand.Parameters.Add(%22Path%22%2C%20%40%22C%3A%5CProgram%20Files%5CWindowsPowerShell%5CModules%5CMicrosoftTeams%5C2.3.1%5CMicrosoftTeams.psd1%22)%3B%0A%2F%2Fcommand.Parameters.Add(%22Path%22%2C%20path)%3B%0ApipeLine.Commands.Add(command)%3B%0ASystem.Collections.ObjectModel.Collection%3CPSOBJECT%3E%20psResult%20%3D%20pipeLine.Invoke()%3B%0AteamsModule%20%3D%20psResult%5B0%5D.BaseObject%20as%20PSModuleInfo%3B%0A%7D%0Ausing%20(Pipeline%20pipeLine1%20%3D%20runspace.CreatePipeline())%0A%7B%0ACommand%20command%20%3D%20new%20Command(%22Import-Module%22)%3B%0Acommand.Parameters.Add(%22ModuleInfo%22%2C%20teamsModule)%3B%0Acommand.Parameters.Add(%22PassThru%22%2C%20true)%3B%0ApipeLine1.Commands.Add(command)%3B%0ASystem.Collections.ObjectModel.Collection%3CPSOBJECT%3E%20psResult1%20%3D%20pipeLine1.Invoke()%3B%0A%7D%3C%2FPSOBJECT%3E%3C%2FPSOBJECT%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2880171%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2881978%22%20slang%3D%22en-US%22%3ERe%3A%20can%20not%20import%20Teams%20PowerShell%20module%20in%20.net%20core%203.1%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2881978%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1194856%22%20target%3D%22_blank%22%3E%40hua%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EPlease%20refer%20below%20doc%20and%20check%20if%20it%20helps%20you%20in%20any%20way.%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fscripting%2Fgallery%2Fconcepts%2Fmodule-psedition-support%3Fview%3Dpowershel%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fscripting%2Fgallery%2Fconcepts%2Fmodule-psedition-support%3Fview%3Dpowershel%26nbsp%3B%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EThanks%2C%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3ENivedipa%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3E------------------------------------------------------------------------------------------------------------------------%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EIf%20the%20response%20is%20helpful%2C%20please%20click%20%22**Mark%20as%20Best%20Response**%22%20and%20like%20it.%20You%20can%20share%20your%20feedback%20via%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Faka.ms%2FDevSupportFeedback)%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3EMicrosoft%20Teams%20Developer%20Feedback%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Blink.%20Click%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Faka.ms%2FDevCommunityEscalationForm%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ehere%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bto%20escalate.%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2884422%22%20slang%3D%22en-US%22%3ERe%3A%20can%20not%20import%20Teams%20PowerShell%20module%20in%20.net%20core%203.1%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2884422%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1183910%22%20target%3D%22_blank%22%3E%40Nivedipa-MSFT%3C%2FA%3E%3CBR%20%2F%3EThanks%20for%20you%20response.%20From%20the%20link%20you%20provided%2C%20it%20seems%20that%20I%20need%20to%20install%20the%20PowerShell%206.0%20or%20above%2C%20In%20my%20windows%20server%2C%20I%20have%20both%20installed%20the%20PowerShell%205.1%20and%20PowerShell%207.1.5%2C%20and%20I%20used%20VS%202019%2C%20.net%20core%203.1%20to%20try%20to%20import%20the%20teams%20module%2C%20I%20can%20import%20the%20teams%20module%20in%20PowerShell%205.1%20desktop%20and%20PowerShell%207.1.5%20desktop%2C%20but%20when%20I%20used%20the%20same%20script%20to%20import%20the%20teams%20module%20in%20VS%202019%2C%20it%20can't%20be%20imported.%20I%20can%20get%20the%20moduleinfo%20from%20Test-ModuleManifest%2C%20but%20when%20I%20used%20the%20moduleinfo%20to%20import%2C%20there%20is%20nothing.%20can%20you%20help%20to%20provide%20some%20suggestions%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2893950%22%20slang%3D%22en-US%22%3ERe%3A%20can%20not%20import%20Teams%20PowerShell%20module%20in%20.net%20core%203.1%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2893950%22%20slang%3D%22en-US%22%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1183910%22%20target%3D%22_blank%22%3E%40Nivedipa-MSFT%3C%2FA%3E%3CBR%20%2F%3EAny%20update%20on%20this%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2913506%22%20slang%3D%22en-US%22%3ERe%3A%20can%20not%20import%20Teams%20PowerShell%20module%20in%20.net%20core%203.1%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2913506%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1194856%22%20target%3D%22_blank%22%3E%40hua%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECould%20you%20please%20check%20below%20document.In%20document%20its%20already%20mention%20that%20for%20installing%20microsoft%20teams%20module%20use%20.NET%20Framework%204.7.2%20or%20later.%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2FMicrosoftTeams%2Fteams-powershell-install%23installing-using-the-powershellgallery%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EInstall%20Microsoft%20Teams%20PowerShell%20-%20Microsoft%20Teams%20%7C%20Microsoft%20Docs%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2918924%22%20slang%3D%22en-US%22%3ERe%3A%20can%20not%20import%20Teams%20PowerShell%20module%20in%20.net%20core%203.1%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2918924%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1183910%22%20target%3D%22_blank%22%3E%40Nivedipa-MSFT%3C%2FA%3E%3CBR%20%2F%3EI%20have%20checked%20my%20environment%2C%20I%20have%20installed%20the%20.NET%20Framework%204.7.2.%20and%20because%20I%20used%20.net%20core%203.1%20in%20my%20project%20%2Cso%20this%20issue%20shouldn't%20be%20related%20to%20.NET%20Framework%20version.%3CBR%20%2F%3Eit%20is%20the%20information%20below%20in%20my%20environment%3A%3CBR%20%2F%3EWindows%3A%20Windows%20Server%202012%20R2%20Datacenter%3CBR%20%2F%3E.NET%20Framework%3A%204.7.2%3CBR%20%2F%3EPowerShell%3A%205.1%20and%207.0.8%3CBR%20%2F%3E.NET%20Core%3A%203.1.101%20and%205.0.402%3CBR%20%2F%3EVS(Project%20used)%3A%20Microsoft%20Visual%20Studio%20Enterprise%202019%20Version%2016.11.5%3CBR%20%2F%3EMicrosoft.PowerShell.SDK(Project%20used)%3A%207.0.8%3CBR%20%2F%3E.NET%20Core(Project%20used)%3A%20netcoreapp3.1%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3ELooking%20forward%20to%20your%20reply%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I tried to import the teams powershell module in .net core 3.1, windows server 2012r2, and the Microsoft.PowerShell.SDK version is 7.0.8. I can get the module via Test-ModuleManifest, but the teams module can't be imported, there is no any errors, I have tried some different teams PS gallery version like 2.3.1, 2.6.0. I can import the teams module in powershell desktop in the same windows environment. 

 

PSModuleInfo teamsModule = null;
using (Pipeline pipeLine = runspace.CreatePipeline())
{
Command command = new Command("Test-ModuleManifest");
//command.Parameters.Add("Path", @"C:\Program Files\WindowsPowerShell\Modules\MicrosoftTeams\2.6.0\MicrosoftTeams.psd1");
command.Parameters.Add("Path", @"C:\Program Files\WindowsPowerShell\Modules\MicrosoftTeams\2.3.1\MicrosoftTeams.psd1");
//command.Parameters.Add("Path", path);
pipeLine.Commands.Add(command);
System.Collections.ObjectModel.Collection<PSObject> psResult = pipeLine.Invoke();
teamsModule = psResult[0].BaseObject as PSModuleInfo;
}
using (Pipeline pipeLine1 = runspace.CreatePipeline())
{
Command command = new Command("Import-Module");
command.Parameters.Add("ModuleInfo", teamsModule);
command.Parameters.Add("PassThru", true);
pipeLine1.Commands.Add(command);
System.Collections.ObjectModel.Collection<PSObject> psResult1 = pipeLine1.Invoke();
}

 

 

 

7 Replies

@hua

Please refer below doc and check if it helps you in any way.

https://docs.microsoft.com/en-us/powershell/scripting/gallery/concepts/module-psedition-support?view...

 

Thanks, 

Nivedipa 

------------------------------------------------------------------------------------------------------------------------ 

If the response is helpful, please click "**Mark as Best Response**" and like it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate. 

@Nivedipa-MSFT
Thanks for you response. From the link you provided, it seems that I need to install the PowerShell 6.0 or above, In my windows server, I have both installed the PowerShell 5.1 and PowerShell 7.1.5, and I used VS 2019, .net core 3.1 to try to import the teams module, I can import the teams module in PowerShell 5.1 desktop and PowerShell 7.1.5 desktop, but when I used the same script to import the teams module in VS 2019, it can't be imported. I can get the moduleinfo from Test-ModuleManifest, but when I used the moduleinfo to import, there is nothing. can you help to provide some suggestions?

@hua 

We are checking on this , we will get back to you once we get any update.

@hua 

Could you please check below document.In document its already mention that for installing microsoft teams module use .NET Framework 4.7.2 or later.
Install Microsoft Teams PowerShell - Microsoft Teams | Microsoft Docs

@Nivedipa-MSFT
I have checked my environment, I have installed the .NET Framework 4.7.2. and because I used .net core 3.1 in my project ,so this issue shouldn't be related to .NET Framework version.
it is the information below in my environment:
Windows: Windows Server 2012 R2 Datacenter
.NET Framework: 4.7.2
PowerShell: 5.1 and 7.0.8
.NET Core: 3.1.101 and 5.0.402
VS(Project used): Microsoft Visual Studio Enterprise 2019 Version 16.11.5
Microsoft.PowerShell.SDK(Project used): 7.0.8
.NET Core(Project used): netcoreapp3.1

 

Looking forward to your reply

@hua ,Is your issue resolved or are you still facing any problem?