MethodsAndPractices / vsteam

PowerShell module for accessing Azure DevOps Services and Azure DevOps Server (formerly VSTS or TFS)

Home Page:https://methodsandpractices.github.io/vsteam-docs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error encountered when runnin Get-VSTeamAccounts command

Graciax8 opened this issue · comments

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

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

commented

@Graciax8, did the above solution solve the issue?

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