diff --git a/pim.sh b/pim.sh index 0afadd4..7ac3c02 100644 --- a/pim.sh +++ b/pim.sh @@ -108,16 +108,6 @@ fuzzy_select_resource_group() { fi } -convert_date() { - local date="$1" - local format="$2" - if [[ $(uname) == "Darwin" ]]; then - date -j -f "%Y-%m-%dT%H:%M:%S" "$date" +"$format" - else - date -d "$date" +"$format" - fi -} - main() { check_dependencies parse_arguments "$@" @@ -142,16 +132,14 @@ main() { fi user_object_id=$(az ad user list --filter "mail eq '$(az account show --query user.name -o tsv)'" --query "[0].id" -o tsv) - start_date=$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ") guid=$(uuidgen | tr '[:upper:]' '[:lower:]') token=$(az account get-access-token --query accessToken -o tsv) subscription_id=$(az account list --query "[?id=='$subscription' || name=='$subscription'].id" -o tsv) - role_eligibility_schedule_instances=$(curl -s -H "Authorization: Bearer $token" -X GET \ - "https://management.azure.com/subscriptions/${subscription_id}/resourceGroups/${resource_group}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances?api-version=2020-10-01&\$filter=asTarget()") - - role_definition_id=$(jq -r --arg resource_group "$resource_group" --arg role "$role" \ - '.value[] | select(.properties.scope | endswith($resource_group)) | select(.properties.expandedProperties.roleDefinition.displayName == $role) | .properties.expandedProperties.roleDefinition.id' <<<"$role_eligibility_schedule_instances" | awk -F'/' '{print $NF}') + role_definition_id=$(curl -s -H "Authorization: Bearer $token" -X GET \ + "https://management.azure.com/subscriptions/${subscription_id}/resourceGroups/${resource_group}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances?api-version=2020-10-01&\$filter=asTarget()" | \ + jq -r --arg resource_group "$resource_group" --arg role "$role" \ + '.value[] | select(.properties.scope | endswith($resource_group)) | select(.properties.expandedProperties.roleDefinition.displayName == $role) | .properties.expandedProperties.roleDefinition.id' | awk -F'/' '{print $NF}') justification="${message// /_}" data=$(cat <