How to get the Application security groups of the Azure VM using PowerShell?

PowerShellMicrosoft TechnologiesSoftware & Coding

To get the Application security groups of the Azure VM using PowerShell, we need to first get the Network Interface of the Azure VM.

The below command will retrieve the NIC name of the Azure VM.

PS C:\> $vm = Get-AzVM -Name TestVM
$nic = (($vm.NetworkProfile.NetworkInterfaces.id).Split('/'))[-1]

Once we have the NIC name, we can use the Get-AzNetworkInterface command to retrieve the NIC information and the Security group.

The below command will retrieve the application security group names using PowerShell.

PS C:\> $nicsettings = Get-AzNetworkInterface -Name $nic
$nicsettings.IpConfigurations.ApplicationSecurityGroups
raja
Published on 31-Aug-2021 09:19:09
Advertisements