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

Error encountered when runnin Get-VSTeamAccounts command #507

Closed Graciax8 closed 1 year ago

Graciax8 commented 1 year ago

Steps to reproduce

$myProfile = Get-VSTeamUserProfile -MyProfile
$orgs = Get-VSTeamAccounts -OwnerId $myProfile.id

Expected behavior

I expected that it will return the organizations which I am the owner

Actual behavior?

I had the following actual outcome...

WARNING: An error occurred: Response status code does not indicate success: 401 (Unauthorized).

On Which OS have you tried it?

macOS

What was your server version?

Azure DevOps Services

Other server version

No response

Log output of used API

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

Log output of $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.1
PSEdition                      Core
GitCommitId                    7.3.1
OS                             Darwin 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:08:47 PST 2022; root:xnu-8792.61.2~4/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
mnieto commented 1 year ago

When you create a Personal Access Token, it is assigned to your default organization If you want Get-VSTeamAccounts could list all your organizations your PAT must have access to all the organizations.

You can edit your PAT and select All accesible organizations as in the below image. Once fixed the PAT configuration the Get-VSTeamAccounts cmdlet should work as expected image

mnieto commented 1 year ago

@Graciax8, did the above solution solve the issue?

SebastianSchuetze commented 1 year ago

No comment for now and I agree that we close this as I also believe that this is the solution to the problem.