PowerShell Script to Install Guest configuration Agent on Windows and Linux Azure Virtual Machines

The Guest Configuration Extension, also known as the Guest Configuration Agent, can be installed on Windows and Linux Azure virtual machines using the PowerShell commands provided below.

Install the Windows Guest Configuration Agent on Azure Windows VMs.

Run the PowerShell script below from either Azure Cloud Shell or Azure PowerShell to install the Windows Guest Configuration Agent.

## PowerShell Script to Install Windows Guest Configuration Agent
$RGName = "_add_rg_name_here"
$VMLocation = "_add_vm_location_here"
$VMName = "_add_avm_name_here"

Set-AzVMExtension `
-Publisher 'Microsoft.GuestConfiguration' `
-Type 'ConfigurationforWindows' `
-Name 'AzurePolicyforWindows' `
-TypeHandlerVersion 1.0 `
-ResourceGroupName '$RGName' `
-Location '$VMLocation' `
-VMName '$VMName' `
-EnableAutomaticUpgrade $true

Install the Linux Guest Configuration Agent on Azure Windows VMs.

Run the PowerShell script below from either Azure Cloud Shell or Azure PowerShell to install the Linux Guest Configuration Agent.

## PowerShell Script to Install Linux Guest Configuration Agent
$RGName = "_add_rg_name_here"
$VMName = "_add_vm_location_here"
$VMName = "_add_avm_name_here"

Set-AzVMExtension 
-Publisher 'Microsoft.GuestConfiguration' `
-Type 'ConfigurationforLinux' `
-Name 'AzurePolicyforLinux' `
-TypeHandlerVersion 1.0 `
-ResourceGroupName '$RGName' `
-Location '$VMName' `
-VMName '$VMName' `
-EnableAutomaticUpgrade $true