Get Application Security Groups of Azure VM Using PowerShell



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
Updated on: 2021-08-31T09:40:48+05:30

539 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements