MethodsAndPractices / vsteam

PowerShell module for accessing Azure DevOps Services and Azure DevOps Server (formerly VSTS or TFS)
https://methodsandpractices.github.io/vsteam-docs/
MIT License
445 stars 155 forks source link

Error accessing [vsteam_lib.QueryCache] #365

Closed jhoneill closed 3 years ago

jhoneill commented 3 years ago

Steps to reproduce

[vsteam_lib.QueryCache]::GetCurrent()

Expected behavior

List of queries

Actual behavior

MethodInvocationException: Exception calling "GetCurrent" with "0" argument(s): "A command is required to add a parameter. A command must be added to the PowerShell instance before adding a parameter."

I think this code

   list = Cache.Shell.AddArgument(queries)
                                 .AddCommand("Select-Object")
                                 .AddParameter("ExpandProperty", "Name")
                                 .AddCommand("Sort-Object")
                                 .Invoke<string>();

will always cause that error. This works.

list = Cache.Shell.AddCommand("Select-Object")
                                 .AddParameter("ExpandProperty", "Name")
                                 .AddCommand("Sort-Object")
                                 .Invoke<string>(queries);