How To Enable Azure Diagnostics For VMs Using PowerShell Script?

1.Install PowerShell ISE , our preferred PowerShell IDE (standard PowerShell works fine as well).

2.Make sure Azure RemoteManagement (Azure RM) modules are installed 

3.Download the script attached to this article

4.Open it with PowerShell

5.Follow instructions on screen to run the script - you will have to log in with Owner role credentials in order to run it successfully. 


Or, you can run the script from PowerShell command line: 

- Enable diagnostics for all VMs :

& '.\enable-diagnostics.ps1' 

- Enable diagnostics for one VM (must provide resource group name) :

& '.\enable-diagnostics.ps1'  -targetRsgName “mygroupname” -targetVmName “vmname”

 - Parameters:

-subscriptionId 1234 

specify the name of the Azure subscription ID to run script against. If not specified, it will be ran against your default subscription


Many of your Azure accounts contains a lot of resources, and Diagnostics On are required for Unigma to gather metrics and generate alerts. Using this script, you can enable Diagnostics across one, many or all of your resources. 

Please follow these steps.



Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Article is closed for comments.