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

Get-VSTeamProject (and the cache) still only returns the top 100 by default #373

Closed ghvanderweg closed 3 years ago

ghvanderweg commented 3 years ago

It seems to me that #363 wasn't fixed in #367.

Get-VSTeamProject still only returns the first 100 projects, and only those projects are saved in the cache.

Adding Top to the PSDefaultParameterValues helps with calling Get-VSTeamProject, but it doesn't increase the cache size. Trying to get a project by name that's not in the first 100 projects still fails validation.

Steps to reproduce

Assuming an account with 129 projects.

(Get-VSTeamProject).Count
$PSDefaultParameterValues.Add("*-VSTeam*:Top",1000)
(Get-VSTeamProject).Count
Get-VSTeamProject -Name 'TestProject101'

Expected behavior

129
129

Name         Description
----         -----------
TestProject101

Actual behavior

100
129
Get-VSTeamProject: Cannot validate argument on parameter 'Name'. 'TestProject101' is invalid

Environment data

OS

Server

> Get-VSTeamAPIVersion
Name                           Value
----                           -----
HierarchyQuery                 5.1-preview
Build                          5.1
DistributedTaskReleased        5.1
ServiceEndpoints               5.0-preview
Graph                          6.0-preview
Release                        5.1
Tfvc                           5.1
TaskGroups                     6.0-preview
MemberEntitlementManagement    6.0-preview
Pipelines                      5.1-preview
Git                            5.1
ExtensionsManagement           6.0-preview
VariableGroups                 5.1-preview.1
Packaging                      6.0-preview
Core                           5.1
Version                        VSTS
DistributedTask                6.0-preview
Policy                         5.1
Processes                      6.0-preview
> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      7.0.3
PSEdition                      Core
GitCommitId                    7.0.3
OS                             Microsoft Windows 10.0.19041
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
SebastianSchuetze commented 3 years ago

thanks! We are checking this.

DarqueWarrior commented 3 years ago

I think I tested this on Azure DevOps Server. Let me see if the service behaves differently.

DarqueWarrior commented 3 years ago

I finally had time to test on Azure DevOps Services. It returns 100 even if you don't pass the top parameter.

DarqueWarrior commented 3 years ago

It is also odd because the 100 it returns is not always the same.

DarqueWarrior commented 3 years ago

To get more than 100 back you have to set the Top parameter. I think I will add a function that makes setting and clearing that easier than having to use PSDefaultParameterValues. So users with more than 100 projects are going to have to called Set-VSTeamDefaultProjectCount. I will also make it sticky like the default project so if you start a new session you don't have to call it again once you set it to a value that works for you.