Officedocs-skypeforbusiness: RuntimeException when importing MicrosoftTeams v2.2.0-preview (PS 5.1)

Created on 15 Apr 2021  ·  9Comments  ·  Source: MicrosoftDocs/OfficeDocs-SkypeForBusiness

Hello,

hot off the press, v2.2.0 is out and I updated to it :D

 David.Eberhardt  C:\                                                                                10:34:34
❯ Import-module microsoftTeams -RequiredVersion 2.2.0
$RuntimeException/   at System.Management.Automation.TypeOps.ResolveTypeName(ITypeName typeName, IScriptExtent errorPos)
   at System.Management.Automation.Language.Compiler.GetAttribute(TypeConstraintAst typeConstraintAst)
   at System.Management.Automation.Language.Compiler.GetRuntimeDefinedParameter(ParameterAst parameterAst, Boolean& customParameterSet, Boolean& usesCmdletBinding)
   at System.Management.Automation.Language.Compiler.GetParameterMetaData(ReadOnlyCollection`1 parameters, Boolean automaticPositions, Boolean& usesCmdletBinding)
   at System.Management.Automation.CompiledScriptBlockData.InitializeMetadata()
   at System.Management.Automation.ScriptBlock.get_Attributes()
   at Microsoft.Teams.ConfigAPI.Cmdlets.Generated.Runtime.PowerShell.GetScriptCmdlet.<ProcessRecord>b__16_0(FunctionInfo fi)
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Microsoft.Teams.ConfigAPI.Cmdlets.Generated.Runtime.PowerShell.GetScriptCmdlet.ProcessRecord()
Get-ScriptCmdlet : Unable to find type
[Microsoft.Teams.ConfigAPI.Cmdlets.Generated.Models.IBeginMoveRequestBody].
At C:\Users\<user>\Documents\WindowsPowerShell\Modules\microsoftTeams\2.2.0\net472\Microsoft.Teams.ConfigAPI.Cmdlets.psm1:42
char:20
+     $cmdletNames = Get-ScriptCmdlet -ScriptFolder $exportsPath
+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Teams...MoveRequestBody:TypeName) [Get-ScriptCmdlet],
    RuntimeException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.Teams.ConfigAPI.Cmdlets.Generated.Runtime.PowerShell.GetScr
   iptCmdlet

 David.Eberhardt  C:\                                                                                10:34:59
❯ Import-module microsoftTeams -RequiredVersion 2.2.0
 David.Eberhardt  C:\                                                                                10:35:19
❯

This failed the first time, but succeeded the second time..


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

All 9 comments

Update:
Digging a bit more into the PSD1 file, I find the following:

    # Script module or binary module file associated with this manifest.
    RootModule             = if ($PSEdition -ne 'Desktop') {
        'netcoreapp2.1\Microsoft.TeamsCmdlets.PowerShell.Custom.dll'
    }
    else {
        'net472\Microsoft.TeamsCmdlets.PowerShell.Custom.dll'
    }

and

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
NestedModules = if($PSEdition -ne 'Desktop')
{
    'netcoreapp2.1\Microsoft.TeamsCmdlets.PowerShell.Connect.dll',
    'netcoreapp2.1\Microsoft.TeamsCmdlets.PowerShell.Custom.dll',
    'netcoreapp2.1\Microsoft.Teams.ConfigAPI.Cmdlets.psd1'
}
else
{
    'net472\Microsoft.TeamsCmdlets.PowerShell.Connect.dll',
    'net472\Microsoft.TeamsCmdlets.PowerShell.Custom.dll',
    'net472\Microsoft.Teams.ConfigAPI.Cmdlets.psd1'
}

The folder though contains a directory called netcoreapp3.1 - which I assume is updated (since it is now 150MB in size :)) and not reflected in the PSD1?

    # Script module or binary module file associated with this manifest.
    RootModule             = if ($PSEdition -ne 'Desktop') {
        'netcoreapp3.1\Microsoft.TeamsCmdlets.PowerShell.Custom.dll'
    }
    else {
        'net472\Microsoft.TeamsCmdlets.PowerShell.Custom.dll'
    }

and

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
NestedModules = if($PSEdition -ne 'Desktop')
{
    'netcoreapp3.1\Microsoft.TeamsCmdlets.PowerShell.Connect.dll',
    'netcoreapp3.1\Microsoft.TeamsCmdlets.PowerShell.Custom.dll',
    'netcoreapp3.1\Microsoft.Teams.ConfigAPI.Cmdlets.psd1'
}
else
{
    'net472\Microsoft.TeamsCmdlets.PowerShell.Connect.dll',
    'net472\Microsoft.TeamsCmdlets.PowerShell.Custom.dll',
    'net472\Microsoft.Teams.ConfigAPI.Cmdlets.psd1'
}

Thanks,
David

No errors received once changed to v3.1, however, using an established session fails with:

❯ Get-CsTenant
Get-CsOnlineSession : Connecting to remote server api.interfaces.records.teams.microsoft.com failed with the
following error message : The WinRM client received an HTTP status code of 403 from the remote WS-Management
service. For more information, see the about_Remote_Troubleshooting Help topic.
At C:\Users\<user>\Documents\WindowsPowerShell\Modules\MicrosoftTeams\2.2.0\net472\SfBORemotePowershellModule.psm1:57 char:22
+     $remoteSession = & (Get-CsOnlineSessionCommand)
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-CsOnlineSession], PSRemotingTransportException
    + FullyQualifiedErrorId : PSRemotingTransportException,Microsoft.Teams.ConfigApi.Cmdlets.GetCsOnlineSession

Invoke-Command : Cannot validate argument on parameter 'Session'. The argument is null or empty. Provide an
argument that is not null or empty, and then try the command again.
At C:\Users\<user>\Documents\WindowsPowerShell\Modules\MicrosoftTeams\2.2.0\net472\SfBORemotePowershellModule.psm1:15161 char:38
+ ...    -Session (Get-PSImplicitRemotingSession -CommandName 'Get-CsTenant ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Invoke-Command], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeCommandComman
   d

To elaborate on this, my PIM Admin roles are active and Connect-MicrosoftTeams was successful, the PSSession is not established as observed with v2.0.0 of the module.

Environment details would be useful for those who want to help 👍 OS/build/.net versions installed/full output of $PSVersionTable etc (I can see it's Windows from your command line though of course!). I can't replicate this on:

Windows 10 x64 Build 19042.928

Name                           Value                                                                                   
----                           -----                                                                                   
PSVersion                      5.1.19041.906                                                                           
PSEdition                      Desktop                                                                                 
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                 
BuildVersion                   10.0.19041.906                                                                          
CLRVersion                     4.0.30319.42000                                                                         
WSManStackVersion              3.0                                                                                     
PSRemotingProtocolVersion      2.3                                                                                     
SerializationVersion           1.1.0.1             


PSChildName                      Version        Release
-----------                      -------        -------
v2.0.50727                       2.0.50727.4927        
v3.0                             3.0.30729.4926        
Windows Communication Foundation 3.0.4506.4926         
Windows Presentation Foundation  3.0.6920.4902         
v3.5                             3.5.30729.4926        
Client                           4.8.04084      528372 
Full                             4.8.04084      528372 
Client                           4.0.0.0               

@robinmalik Thank you for submitting feedback and contributing to the docs. We are currently investigating this.

Of course :) - Apologies, here:
Running on Windows 10 Version 20H2 (OS Build 19042.867) myself

❯ $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.19041.610
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.610
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1


❯ Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse |
>> Get-ItemProperty -name Version,Release -EA 0 |
>> Where { $_.PSChildName -match '^(?!S)\p{L}'} |
>> Select PSChildName, Version, Release

PSChildName                      Version        Release
-----------                      -------        -------
v2.0.50727                       2.0.50727.4927
v3.0                             3.0.30729.4926
Windows Communication Foundation 3.0.4506.4926
Windows Presentation Foundation  3.0.6920.4902
v3.5                             3.5.30729.4926
Client                           4.8.04084      528372
Full                             4.8.04084      528372
Client                           4.0.0.0

@robinmalik - thank you, have written myself a little script to gather this information now - adding it to my profile so that I can provide better feedback 😄

Hi @DEberhardt and @robinmalik, thank you for your feedback.

Usually, this kind of issue should be managed through a support ticket, but as in this case is an issue with a preview version of the Teams PowerShell module, I'll send this feedback to the product group.

Interesting. I have a support ticket open right now regarding the recent performance drop when running PS Commands with MicrosoftTeams v2.0.0 (Get-CsOnlineUser takes 5-18s to return a result, instead of 1.5s) and they cannot help me at all...

My apologies @DEberhardt, but here we are limited to documentation issues and improvements.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adyst picture adyst  ·  4Comments

Lowell-Syncrety picture Lowell-Syncrety  ·  4Comments

Mlavieri picture Mlavieri  ·  6Comments

JAK1047 picture JAK1047  ·  6Comments

DevJonBirkett picture DevJonBirkett  ·  6Comments