# NOTE: # Make sure you are logged into the az cli before running this # Command: az login # Get the JSON data from Azure CLI $jsonData = az role definition list | ConvertFrom-Json # Create an empty array to store the formatted strings $formattedRoles = @() foreach ($role in $jsonData) { $roleType = if ($role.roleType -eq "BuiltInRole") { "Built-in role" } else { "Custom role" } $formattedRole = @" $roleType $($role.roleName) Description $($role.description) ID $($role.name) "@ $formattedRoles += $formattedRole } # Join all formatted roles into a single string $output = $formattedRoles -join "`n" # Write the output to a text file $output | Out-File -FilePath "azure_roles.txt" -Encoding UTF8 Write-Host "Azure roles have been written to azure_roles.txt"