Forum Discussion
can not import Teams PowerShell module in .net core 3.1
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();
}
- Nivedipa-MSFTMicrosoft
Please refer below doc and check if it helps you in any way.
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.
- huaCopper Contributor
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?- huaCopper ContributorNivedipa-MSFT
Any update on this?