Hello @FATOBA, KIMBERLY ,
Welcome to Microsoft Q&A Platform. Thank you for reaching out & hope you are doing well.
I understand that you are running the "Remove-AzNetworkSecurityGroup" PowerShell command to delete an NSG, but this NSG is currently associated with a subnet, and you don't have direct access to Azure portal to dissociate it from the subnet, so the deletion is stuck. You need the PowerShell command to dissociate NSG from subnet.
You can find the PowerShell commands for dissociating a network security group from a subnet in the below doc:
Instead of declaring the NSG, you can add $null to the Set-AzVirtualNetworkSubnetConfig command to disassociate the NSG as below:
## Place the virtual network configuration into a variable ##
$vnet = Get-AzVirtualNetwork -Name vnetname -ResourceGroupName rgname
## Update the subnet configuration to disassociate the NSG using $null ##
Set-AzVirtualNetworkSubnetConfig -Name subnetname -VirtualNetwork $vnet -AddressPrefix 10.0.0.0/24 -NetworkSecurityGroup $null
## Update the virtual network ##
Set-AzVirtualNetwork -VirtualNetwork $vnet
I tried it in my lab and it works as you can see from the below screenshot:
Then you can delete the NSG using the below command:
Remove-AzNetworkSecurityGroup -Name "nsgname" -ResourceGroupName "rgname"
Kindly let us know if the above helps or you need further assistance on this issue.
Please "Accept the answer" if the information helped you. This will help us and others in the community as well.