Hello there,
Found this script online and might help you out.
Specify your Azure resource details
$subscriptionId = "your-subscription-id"
$resourceGroupName = "your-resource-group-name"
$nsgName = "your-nsg-name"
Authenticate to Azure (if not already authenticated)
Connect-AzAccount
Get the NSG object
$nsg = Get-AzNetworkSecurityGroup -ResourceGroupName $resourceGroupName -Name $nsgName
Define the updated rule parameters
$ruleNameToUpdate = "rule-name-to-update"
$newRulePriority = 110
Find the rule to update
$ruleToUpdate = $nsg.SecurityRules | Where-Object { $_.Name -eq $ruleNameToUpdate }
Update the rule priority
$ruleToUpdate.Priority = $newRulePriority
Update the NSG with the modified rule
$nsg | Set-AzNetworkSecurityGroup
Print a message indicating the rule has been updated
Write-Host "NSG rule '$ruleNameToUpdate' has been updated with new priority: $newRulePriority"
Make sure to replace the placeholders (your-subscription-id, your-resource-group-name, your-nsg-name, rule-name-to-update, and 110) with your actual values.
Before running the script, please ensure you have the Azure PowerShell module installed, and you've authenticated using Connect-AzAccount.
Hope this resolves your Query !!
--If the reply is helpful, please Upvote and Accept it as an answer--