Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,560,359
Community Members
 
Community Events
185
Community Groups

Get users in organization via Powershell

Does anyone have a existing way to do the API call 'Get Users in Organization' via powershell? I tried JiraPS but that can only give me group members and its just their name where as this gives ID, timezone and email etc.

Otherwise does someone have an idea how to connect? Seems to be totally different to how i connect to insight in my InsightPS module.

 

 

 

3 answers

1 accepted

1 vote
Answer accepted
$username = "email address"
$password = "api key"

$ServiceDeskID
 = "Service Desk Number"
$Server = "jira server url"

# Convert the username + password into a Base64 encoded hash for basic authentication
$pair = "${username}:${password}"
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$base64 = [System.Convert]::ToBase64String($bytes)
$headers = @Authorization = "Basic $base64" }
$headers.Add('content-type' , 'application/json')
$headers.Add('X-ExperimentalApi' , 'opt-in')

$start
 = 0
$limit = 50 #Max results

$Customers = @()

$Customers = do {    
$URL = [System.UriBuilder]"$Server/rest/servicedeskapi/servicedesk/$ServiceDeskID/customer?limit=$limit&start=$start"    
$Response = Invoke-RestMethod -Uri $URL.Uri -Headers $headers -Method GET    
$Response.values
$start += $limit
until (
$Response.isLastPage -eq $true)

My issue was just with that API call. Seems to be fine for all others and turns out that wasn't what i wanted anyway. 

very good script I was able to make this work to export all users from a datacenter instance, this is awesome! Thanks Gary! 

All the examples that I can find use Basic auth which doesn't work anymore.

Do we need to generate a JWT header or can we just provide username\APIkey?

Any help to point me in the right direction would be helpful.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events