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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Bulk move users from one group to another Edited


I need to bulk move users from one group to another. This is for JIRA cloud and confluence


Or Is there way to edit the permissions of the users in group in bulk? 

2 answers

Unfortunately, the answer is no for both.

#region Login
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

$user = Read-Host -Prompt 
'Input an Admin name: '
$pass = Read-Host -Prompt 'Input the Admin key: '
$pair = "$($user):$($pass)"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
$basicAuthValue = "Basic $encodedCreds"
$Headers = @{
Authorization = $basicAuthValue
#endregion Login

#region remove file
$FileName = ".\users.csv"
if (Test-Path .\*.csv) 
Remove-Item .\*.csv
#endregion remove file

#region get id's from group
$groupFrom = Read-Host -Prompt 'Input group name to copy users from '
$groupMembers = [uri]::EscapeUriString($groupFrom)

$URL = "https://<>$groupMembers"

    $x = (((Invoke-WebRequest -UseBasicParsing -Method GET -Uri $URL -Headers $headers -SessionVariable session -ContentType 'application/json').Content) | ConvertFrom-Json)
    Out-File -FilePath $FileName -InputObject $($x.values.accountId) -Append
      if($x.isLast -ne "true"){
        $URL = $x.nextPage
        $x1 = (((Invoke-WebRequest -UseBasicParsing -Method GET -Uri $URL -Headers $headers -SessionVariable session -ContentType 'application/json').Content) | ConvertFrom-Json)        
Out-File -FilePath $FileName -InputObject 
$($x1.values.accountId) -Append
while($x.isLast -ne "true")
#endregion get id's from group

#region copy to group
$groupTo = Read-Host -Prompt 'Input group name to copy users to '
$group = [uri]::EscapeUriString($groupTo) 

$FileName = Get-Content users.csv

foreach ($ID in $FileName) {
Invoke-WebRequest -Headers $headers -Method POST -Body (@{"accountId"="$($ID)";}|ConvertTo-Json) -Uri https://<>$group -ContentType application/json
#endregion copy to group

Here's a powershell script I've written up which does the trick for me. Simply just prompts the user for a group name and then grabs the ID's from that group to a file named "users.csv" in the same directory. It will then prompt for the group to add the users to and iterate over the file one by one. Hope this helps someone. 

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you