Enabling Azure VM memory metrics using Powershell for Windows VMs

Document created by richard.stinton on Jan 21, 2020Last modified by richard.stinton on Jan 22, 2020
Version 3Show Document
  • View in full screen mode

This document explained how to enable basic memory metrics in Azure VMs manually.  When you have more than a few this can be quite tedious.  Azure Powershell enables the automation of the process.  After much searching of the interwebs I came across some scripts used originally for another product to do the same thing, but the scripts were out of date due to changes in Azure and Powershell. I've managed to update the scripts to work with Windows VMs, but not with Linux ones which use a slightly different process.  However, I've got Linux working using the Azure CLI (which most Linux-types would use anyway). Another post on that soon.


There are four Powershell modules in the script, a primary module and 3 others that are called by the primary.  The script supports both classic and ARM. There are various switches to the script that allow you to select subscription, VM, etc. Remember that this only works for Windows so you'll need the switch -OsType 'Windows'. You'll also notice 4 XML files which describe which counters to turn on.  The files with Orig in the filename are the original longer set of counters that the original product wanted, while the filename without Orig is a shorter set of just memory metrics.


.\EnableDiag.ps1 –DeploymentModel 'Arm' -OsType 'Windows'

Usual disclaimer: While I've tested this in my Azure subscription, I can take no responsibility for running in other accounts/subscriptions.  You can use the -ChooseVM switch to test on a single VM


Example execution in my subscription