Using the Octopus Deploy API how can I find which users have a role assigned to them?

My compliance team got in touch and they wanted to know who has system administration rights, and who can view Projects within Octopus.

I need to find a list of users who have the System administrator role and the ProjectViewer role assigned to them in Octopus.

Is there a way to find this out?

This can be achieved using the Octopus REST API.

We have created a script which will find users in a specific role in our OctopusDeploy-API github repo here.

Just set the working variables at the top of that script, so for the Project Viewer role set it as below:

$OctopusServerUrl = "https://url-to-your-octopus-server"
$RoleName = "Project Viewer"

Example output:

PS C:\Users> D:\OctopusDeploy-Api\REST\PowerShell\Users\FindUsersWithUserRole.ps1
Team: Space Managers
External security groups:
Team: Test team
External security groups: