TfsCmdlets
                                
                                 TfsCmdlets copied to clipboard
                                
                                    TfsCmdlets copied to clipboard
                            
                            
                            
                        Get-TfsTeamProject : Method not found: 'Newtonsoft.Json.JsonSerializerSettings
When I run this command I get this error. Windows 2016 server.
PS C:\Users\Administrator> Get-TfsTeamProject Get-TfsTeamProject : Method not found: 'Newtonsoft.Json.JsonSerializerSettings System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.get_SerializerSettings()'. At line:1 char:1
- Get-TfsTeamProject
- 
+ CategoryInfo : NotSpecified: (:) [Get-TfsTeamProject], MissingMethodException + FullyQualifiedErrorId : MissingMethodException,TfsCmdlets.Cmdlets.TeamProject.GetTeamProject
Same issue.
PS A:> $PSVersionTable
Name Value
PSVersion 5.1.17763.3770 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.17763.3770 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1
PS A:> Get-Module TfsCmdlets
ModuleType Version Name
Binary 2.6.0 TfsCmdlets
Windows Server 2019 version 1809 is a rather old build. I'm assuming neither of you can either update Windows PowerShell (by installing the latest Windows Management Framework) or install PowerShell 7 in those servers, right? That would be the easiest/fastest workaround.
Anyways, I'm trying to repo this bug in a VM and I'll see if I can come up with a fix or a workaround. I'll let you know how it goes.
@MSIH @PhmAnthony any chance could you share the loaded modules in your PowerShell session, and also the copies of Newtonsoft.Json loaded in the PS AppDomain?
Get-Module
[System.AppDomain]::CurrentDomain.GetAssemblies() | where Location -like *newton* | select FullName, Location
This error usually stems from a module being loaded before TfsCmdlets which happens to have an older version of Newtonsoft.Json. Unfortunately, proper module isolation is something very tricky to be done in Windows PowerShell 5.x (.NET Core / PS7 improves things in that regard).
Besides sharing your loaded modules, could you please run a PS session without loading your profile (powershell -noprofile), then load TfsCmdlets and try to run your commands again? I'm trying to find out whether a module loaded earlier might be breaking TfsCmdlets.
Windows Server 2019 version 1809 is a rather old build. I'm assuming neither of you can either update Windows PowerShell right?
Correct. Unfortunately, I am locked into this OS for the time being.
If I use PowerShell ISE, PowerShell Tools for Visual Studio, or Developer PowerShell for Visual Studio 2019 then I get no error. If I use Visual Studio Code, then I get the error.
Visual Studio Code
ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}
Manifest   3.0.0.0    Microsoft.PowerShell.Security       {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-AuthenticodeSignature...}
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Script     1.1.30     Plaza                               {Add-MachinePath, Assert-FolderExists, Assert-TargetFolderExists, Backup-SingleFileFromPhmEnvironment...}
Script     0.2.0      PowerShellEditorServices.Commands   {Clear-Host, ConvertFrom-ScriptExtent, ConvertTo-ScriptExtent, Find-Ast...}
Binary     0.2.0      PowerShellEditorServices.VSCode     {Close-VSCodeHtmlContentView, New-VSCodeHtmlContentView, Set-VSCodeHtmlContentView, Show-VSCodeHtmlContentView...}
Script     2.2.6      PSReadLine                          {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PSReadLineKeyHandler, Set-PSReadLineKeyHandler...}
Binary     2.6.0      TfsCmdlets                          {Add-TfsGroupMember, Add-TfsTeamAdmin, Add-TfsTeamMember, Add-TfsWorkItemLink...}
FullName : Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
Location : C:\Users\PHMIT.AMISSICO\.vscode\extensions\ms-vscode.powershell-2023.2.1\modules\PowerShellEditorServices\bin\Common\Newtonsoft.Json.dll
FullName : Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
Location : C:\Users\PHMIT.AMISSICO\.vscode\extensions\ms-vscode.powershell-2023.2.1\modules\PSScriptAnalyzer\1.21.0\Newtonsoft.Json.dll
FullName : Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
Location : C:\Program Files\WindowsPowerShell\Modules\TfsCmdlets\2.6.0\Lib\Desktop\Newtonsoft.Json.dll
PowerShell ISE
ModuleType Version    Name                                ExportedCommands                                                                                                                                                                                                                         
---------- -------    ----                                ----------------                                                                                                                                                                                                                         
Script     1.0.0.0    ISE                                 {Get-IseSnippet, Import-IseSnippet, New-IseSnippet}                                                                                                                                                                                      
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}                                                                                                                                                                       
Manifest   3.0.0.0    Microsoft.PowerShell.Security       {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-AuthenticodeSignature...}                                                                                                                                                
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}                                                                                                                                                                                
Manifest   3.0.0.0    Microsoft.WSMan.Management          {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, Enable-WSManCredSSP...}                                                                                                                                                          
Binary     2.6.0      TfsCmdlets                          {Add-TfsGroupMember, Add-TfsTeamAdmin, Add-TfsTeamMember, Add-TfsWorkItemLink...}                                                                                                                                                        
FullName : Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
Location : C:\Program Files\WindowsPowerShell\Modules\TfsCmdlets\2.6.0\Lib\Desktop\Newtonsoft.Json.dll
PowerShell Tools for Visual Studio
ModuleType Version    Name                                ExportedCommands                                                                                                                                                                                                                                  
---------- -------    ----                                ----------------                                                                                                                                                                                                                                  
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}                                                                                                                                                                                
Manifest   3.0.0.0    Microsoft.PowerShell.Security       {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-AuthenticodeSignature...}                                                                                                                                                         
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}                                                                                                                                                                                         
Binary     1.0.0.0    PowerShellProTools.VSCode           {Get-CompletionItem, Get-PoshToolsVariable, Out-PoshToolsVariable, Measure-Block...}   
Developer PowerShell for Visual Studio 2019
ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Binary     16.0.0.0   Microsoft.VisualStudio.DevShell     {Enter-VsDevShell, Send-VsDevShellTelemetry}
Script     1.4.7      PackageManagement                   {Find-Package, Find-PackageProvider, Get-Package, Get-PackageProvider...}
Script     1.0.0.1    PowerShellGet                       {Find-Command, Find-DscResource, Find-Module, Find-RoleCapability...}
Binary     2.6.0      TfsCmdlets                          {Add-TfsGroupMember, Add-TfsTeamAdmin, Add-TfsTeamMember, Add-TfsWorkItemLink...}
FullName                                                                            Location
--------                                                                            --------
Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed  C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\PrivateAssemblies...
Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed C:\Program Files (x86)\WindowsPowerShell\Modules\TfsCmdlets\2.6.0\Lib\Desktop\Newtonsoft.Jso...