How to enable the Azure VM accelerated settings using PowerShell?


To enable the Azure VM accelerated settings using PowerShell, we need to enable the EnableAcceleratedNetworking property on the NIC attached to the VM.

$vm = Get-AzVM -Name TestVM
$nicname = (($vm.NetworkProfile.NetworkInterfaces.id).Split('/'))[-1]
$nicsetting = Get-AzNetworkInterface -ResourceGroupName $vm.ResourceGroupName -
Name $nicname
$nicsetting.EnableAcceleratedNetworking = $true

In the above example, we are setting AN settings on the Azure VM “TestVM”. To set the AN setting on the particular subscription, use the below command. Make sure that you are connected to the proper subscription using the Set-AzContext command.

Get-AzVM | Select Name, ResourceGroupName,`
   @{N='Accelerated Netoworking'; E={
      $nic = (($_.NetworkProfile.NetworkInterfaces.id).Split('/'))[-1]
      $nicsetting = Get-AzNetworkInterface -
      ResourceGroupName $_.ResourceGroupName -Name $nic
      $nicsetting.EnableAcceleratedNetworking = $true
      if($nicsetting.EnableAcceleratedNetworking){"Enabled"}
      else{"Disabled"}
   }}

To set the AN settings on the VMs of the particular resource group, use Get-AzVM - ResourceGroupName ‘ResourceGroup’ instead of Get-AzVM in the above code.

Updated on: 31-Aug-2021

164 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements