Closed shazaman23 closed 3 years ago
Just a comment on this, in the example provided you should not be able to see myproject
in the results if you run Get-VsTeamProject
but you do see myproject
in the results if you run Get-VsTeamProject -top 500
Thx @shazaman23. Just to clarify, you are saying that without using the top
parameter you expect that there is a better error message?
Can you clarify your expected behavior a bit?
I'm having this issue on several of the cmdlets. It seems anything that is trying to validate the projectName if it is not listed within the first 100 results.
The following command is an example of this behavior, which worked as expected in the 6.5.1 version of the module.
Import-Module vsteam -MaximumVersion 7.1.1
Get-VSTeamProject -Name "RxSourcing"
Get-VSTeamProject : Cannot validate argument on parameter 'Name'. 'RxSourcing' is invalid
At line:1 char:25
+ Get-VSTeamProject -Name "RxSourcing"
+ ~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-VSTeamProject], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Get-VSTeamProject
remove-module vsteam
Import-Module vsteam -MaximumVersion 6.5.1
Get-VSTeamProject -Name "RxSourcing"
Name Description
---- -----------
RxSourcing A DevOps project
I'm having this issue on several of the cmdlets. It seems anything that is trying to validate the projectName if it is not listed within the first 100 results.
The following command is an example of this behavior, which worked as expected in the 6.5.1 version of the module.
Import-Module vsteam -MaximumVersion 7.1.1 Get-VSTeamProject -Name "RxSourcing" Get-VSTeamProject : Cannot validate argument on parameter 'Name'. 'RxSourcing' is invalid At line:1 char:25 + Get-VSTeamProject -Name "RxSourcing" + ~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Get-VSTeamProject], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,Get-VSTeamProject remove-module vsteam Import-Module vsteam -MaximumVersion 6.5.1 Get-VSTeamProject -Name "RxSourcing" Name Description ---- ----------- RxSourcing A DevOps project
Possibly is related to the InternalCache not caching all of the projects?
https://github.com/MethodsAndPractices/vsteam/blob/trunk/Source/Classes/Cache/InternalCache.cs#L61
Right. As @morrell mentioned, it is occurring on any command that takes the project name as a parameter. I can pass the top flag to the Get-VsTeamProject to return enough results to see my project, but when I run Set-VSTeamDefaultProject it says that I am using an invalid project name. I believe this is because the module is only caching the top 100 projects and using those to validate the project name parameter on any command.
The quickest short term fix is to edit vsteam.functions.ps1 , search for the line
function Get-VSteamProject
and about 8 lines below that change
$top = 100
to a big enough number to get all the projects. Save and reload.
@DarqueWarrior can make a call at a later point on the value of Get-VSteamProject
only returning some projects byDefault, IMHO it should be all by default and paged if -TOP is specified and non zero, but I don't know why the limit was put in so there may be a good reason.
I am also able to resolve this momentarily by importing the version 6.5.1 of the module (where this was still working). But we may want to use the latest version soon so I was hoping this issue could be resolved without running a custom build of the module.
I will be working on this soon. Thanks for the detailed issue.
Another solution that does not require changing any code is to set a default value for Top.
$Global:PSDefaultParameterValues["*-vsteam*:top"] = 500
This will pass 500 to Top.
I close this since with an earlier commit a new cmdlet was added that lets you set the default $top parameter number for projects.
I experienced this error recently. Using the source code for function Get-VSteamProject (referred to earlier by @jhoneill in this thread) as inspiration, my fix was to set the _$env:TEAMPROJECTCOUNT value to something greater than 100 so.
This worked for me:
$env:TEAM_PROJECTCOUNT = 200
$env:TEAM_PROJECTCOUNT = 200
But probably better to use the Set-VSTeamDefaultProjectCount which seems to do the same thing (I noticed by chance)
In an org that has more than 100 projects, if your project doesn't show up in the first 100 results of Get-VsTeamProject, commands that use a project parameter fail with the error
Cannot validate argument on parameter 'Project'. 'myproject' is invalid
Steps to reproduce
Expected behavior
Actual behavior
Environment data
OS
Server