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

Import-Module fails with error message when default Project not with common scopes set #467

Closed mpiederiet closed 1 year ago

mpiederiet commented 2 years ago

Steps to reproduce

Expected behavior

I expected that I could import the module without issues

Actual behavior?

The Import-Module failed with error message You must call Set-VSTeamAccount before calling any other functions in this module

On Which OS have you tried it?

Windows

What was your server version?

Azure DevOps Services

Other server version

No response

Log output of used API

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                     :
Wiki                        : 6.0
WorkItemTracking            : 6.0-preview.1

Log output of $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.2.3
PSEdition                      Core
GitCommitId                    7.2.3
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0, 5.0, 5.1.10032.0, 6.0.0, 6.1.0, 6.2.0, 7.0.0, 7.1.0, 7.2.3}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
mpiederiet commented 2 years ago

I already found out that the Import-Module fails because of this line in VSTeam.psm1: https://github.com/MethodsAndPractices/vsteam/blob/41f28b4d9929ed8778e2d001ec3d54d4968cb1aa/Source/VSTeam.psm1#L32

The Get-VSTeamProject command can't be executed here because there are no stored credentials. I think it would be a good idea to check for credentials before executing Get-VSTeamProject Maybe even better: check for stored credentials, then check for stored default Project name, then check whether that project still exists and throw a warning if it doesn't.

SebastianSchuetze commented 1 year ago

Working on it now