Copy Azure Role scripts

This commit is contained in:
robbwilcox
2024-10-05 12:23:48 -05:00
parent c6f38e7baf
commit d15fc821c6
7 changed files with 271 additions and 0 deletions

30
Get-AzureRoles.ps1 Normal file
View File

@@ -0,0 +1,30 @@
# 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"