Hi
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?
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://<>.atlassian.net/rest/api/3/group/member?groupname=$groupMembers"do{ $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.csvforeach ($ID in $FileName) {Invoke-WebRequest -Headers $headers -Method POST -Body ({"accountId"="$($ID)";}|ConvertTo-Json) -Uri https://<>.atlassian.net/rest/api/3/group/user?groupname=$group -ContentType application/json}#endregion copy to groupexit
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.
It looks like you're new here. Sign in or register to get started.