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
442 stars 155 forks source link

Add-VSTeamWorkItem fails if project is beyond the first 100 projects. #444

Closed jackfruhecolab closed 2 years ago

jackfruhecolab commented 2 years ago

Steps to reproduce

get-vsteamproject -id "myproject" #works
add-vsteamworkitem -title "test" -workitemType "task" -parentid 123 -project "myproject" #fails 
Cannot validate argument on parameter 'Projectname'. 'myproject' is invalid

Expected behavior

expected to work.

Actual behavior

Environment data

OS

Server

$vstermverstiontable is empty

> Get-VSTeamAPIVersion
Billing                     : 5.1-preview.1
Build                       : 5.1
Core                        : 5.1
DistributedTask             : 6.0-preview
DistributedTaskReleased     : 5.1
ExtensionsManagement        : 6.0-preview
Git                         : 5.1
Graph                       : 6.0-preview
HierarchyQuery              : 5.1-preview
MemberEntitlementManagement : 6.0-preview
Packaging                   : 6.0-preview
Pipelines                   : 5.1-preview
Policy                      : 5.1
Processes                   : 6.0-preview
Release                     : 5.1
ServiceEndpoints            : 5.0-preview
TaskGroups                  : 6.0-preview
Tfvc                        : 5.1
VariableGroups              : 5.1-preview.1
Version                     : AzD
> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.19041.1320
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1320
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Special Note:

I see a constant theme in the VSTeam commands: If there are more than 100 projects, and the project being worked on is past the first 100, the command fails. I can only assume that the PS commands call the API to fetch a project list, which returns the first 100, and then the PS command filters from there.

Get-VSTeamProject -ID "projectname" works, and returns a bunch of info including the GUID of the project and the URL

Is there a way that all these commands impacted by the 100 limit could optionally take $project.id or $project.url (and have the cmdlet use that to directly address the project instead of pulling the list of projects and then filtering?)

SebastianSchuetze commented 2 years ago

Hi @jackfruhecolab please try Set-VSTeamDefaultProjectCount -Count 500 before calling any function that is using a project specific parameter.

It is not a bug. We try to prefill the project list when using the project parameter. And this is by default 100. So if you have more, then you need to set the new limit beforehand.

SebastianSchuetze commented 2 years ago

Hi @jackfruhecolab does this hint fixes it for you? I would close it for now and also the other one since it is the same solution.

If you still have problems you can comment on it and we will check again.