Enabling Boot Diagnostics Using PowerShell

In this blog post, we will discuss how to enable boot diagnostics on Azure VMs using PowerShell.

Azure Virtual Machines (VMs) are widely used by organizations to run a variety of workloads. In order to ensure that these VMs are running smoothly, it is important to monitor their boot process and diagnose any issues that may occur. This is where boot diagnostics come in handy. Boot diagnostics provide detailed information about the boot process of a VM, including logs, screenshots, and serial console output.

Connect to Azure

The first step is to connect to Azure using PowerShell. To do this, open PowerShell and run the following command:


This will prompt you to log in to your Azure account.

Get the VM object

Once you are connected to Azure, you need to get the VM object that you want to enable boot diagnostics on. You can do this by running the following command:

$vm = Get-AzVM -ResourceGroupName <resource-group-name> -Name <vm-name>

Replace <resource-group-name> and <vm-name> with the name of your resource group and VM.

Enable boot diagnostics

Now that you have the VM object, you can enable boot diagnostics by running the following command:

Set-AzVMBootDiagnostics -VM $vm -Enable -ResourceGroupName <resource-group-name> -StorageAccountName <storage-account-name>

Replace <resource-group-name> with the name of your resource group, and <storage-account-name> with the name of the storage account where you want to store the boot diagnostics data.

Verify boot diagnostics

To verify that boot diagnostics are enabled, you can run the following command:

Get-AzVMBootDiagnosticsData -VM $vm -ResourceGroupName <resource-group-nam

Full code

The full code to enable boot diagnostics on Azure Virtual Machine is listed below.


$vm = Get-AzVM -ResourceGroupName <resource-group-name> -Name <vm-name>

Set-AzVMBootDiagnostics -VM $vm -Enable -ResourceGroupName <resource-group-name> -StorageAccountName <storage-account-name>

Get-AzVMBootDiagnosticsData -VM $vm -ResourceGroupName <resource-group-name>

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.