public/Get-AzureRMWebHookSeverity.ps1

function Get-AzureRMWebHookSeverity {
    <#
    .DESCRIPTION
    Utilized to determine the string severity value to be setup with the Azure webhook for Azure metric notification.
     
    .PARAMETER AlertPriority
    Alert priority utilized to calculate severity. Acceptable values are P1, P2, and P3
     
    .PARAMETER ResourceClass
    Specific resource class type of the resource to be setup with the webhook. Acceptable values are Class A, Class B, Class C.
     
    .EXAMPLE
    Get-AzureRMWebHookSeverity -AlertPriority "P1" -ResourceClass "Class B"
    #>

    [CmdletBinding()]
    param (
        # The alert priority to utilize to calculate severity.
        [Parameter(Mandatory=$true)]
        [ValidateSet("P1","P2","P3")]
        [string]
        $AlertPriority,
        # The specific Resource Class type of the resource to be setup with the webhook.
        [Parameter(Mandatory=$true)]
        [ValidateSet("Class A","Class B","Class C")]
        [string]
        $ResourceClass
    )
    process {
        $alertPriorityWeight = switch ($alertPriority) {
            "P1" { 0 }
            "P2" { 5 }
            "P3" { 10 }
        }

        $resourceClassWeight = switch ($resourceClass) {
            "Class A" { 0 }
            "Class B" { 5 }
            "Class C" { 10 }
        }

        $finalSeverityWeight = $alertPriorityWeight + $resourceClassWeight

        switch ($finalSeverityWeight) {
            { $PSItem -le 4 } { return 'Urgent' }
            { ($PSItem -ge 5) -and ($PSItem -le 9)} { return 'High' }
            { ($PSItem -ge 10) -and ($PSItem -lt 15) } { return 'Normal' }
            { $PSItem -ge 15 } { return 'Low' }
            Default { return 'Low' }
        }
    }
}