AtlassianPS / JiraPS

PowerShell module to interact with Atlassian JIRA
https://AtlassianPS.org/module/JiraPS
MIT License
323 stars 131 forks source link

Get-JiraUser doesn't return groups unless Username parametersupplied #319

Closed JohnLBevan closed 5 years ago

JohnLBevan commented 5 years ago

Description

Running Get-JiraUser -Username 'MyUsername' | FL * returns a user object with Groups property holding a list of all groups to which a user belongs.

However, running Get-JiraUser returns only the current user; but the Groups property is empty.

Steps To Reproduce

'With Explicit Username'
Get-JiraUser -Username $cred.Username | Select-Object -ExpandProperty Groups
'With No Username (defaults to current user)'
Get-JiraUser | Select-Object -ExpandProperty Groups

Expected behavior

A list of the groups to which the user belongs should be returned

Your Environment

$PSVersionTable

Name                           Value                                                                                                                                                          
----                           -----                                                                                                                                                          
PSVersion                      5.1.17134.228                                                                                                                                                  
PSEdition                      Desktop                                                                                                                                                        
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                        
BuildVersion                   10.0.17134.228                                                                                                                                                 
CLRVersion                     4.0.30319.42000                                                                                                                                                
WSManStackVersion              3.0                                                                                                                                                            
PSRemotingProtocolVersion      2.3                                                                                                                                                            
SerializationVersion           1.1.0.1    
Get-Module JiraPS -ListAvailable | Select Name, Version
$PSVersionTable
Name   Version
----   -------
JiraPS 2.8.6  

Possible Solution

Instead of using $selfResourceUri use the $searchResourceUri URI, passing the current session credentials' username value to the Username parameter.

lipkau commented 5 years ago

Your proposed solution will not work. unfortunately. Not everyone uses sessions.

This can be fixed by fetching the user with $selfResourceUri and using that information for Get-JiraUser -Username $return