Remove DVD drive on Azure virtual machine

When you deploy a new virtual machine, for example Windows Server 2016/2019 or 2022, you’ll get the C: drive with the operating system, the D: drive for the TEMP storage (most of the VM types) and a DVD drive.

The DVD drive is not needed in some situations, for example on domain controllers. This type of servers you want to harden the security as much as possible. So, for domain controllers we’re deploying in our customer environments, we want to disable the DVD drive.

We run the following command when deploying new domain controllers in Azure.

## Disable DVD drive
Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\cdrom -Name Start -Value 4 -Type DWord

After this step, reboot the server and your DVD drive is gone!




Error: ‘User failed validation to purchase resources’ when deploying a virtual machine

Today I’ve deployed a new virtual machine within Azure using the Windows Server 2022 Azure Edition Preview Marketplace image. After running my Powershell script, I received an error:
’User failed validation to purchase resources. Error message: ‘You have not accepted the legal terms on this subscription: …..’


So, let’s take a look at the legal terms, also using Powershell. I’ve used a couple of variables.

$azureVmPublisherName = "MicrosoftWindowsServer"
$azureVmOffer = "microsoftserveroperatingsystems-previews"
$azureVmSkus = "windows-server-2022-azure-edition-preview"
$Version = "latest"

Get-AzMarketplaceTerms -Publisher $azureVmPublisherName -Product $azureVmOffer -Name $azureVmSkus


As you can see, the legal terms are not accepted yet!! With a small Powershell command, we can accept the legal terms.

Get-AzMarketplaceTerms -Publisher $azureVmPublisherName -Product $azureVmOffer -Name $azureVmSkus | Set-AzMarketplaceTerms -Accept


Now you’re good to go!!

PowerCLI: An Aspiring Automator’s Guide

Getting into scripting can be daunting. It’s easier to just use existing scripts found online, but if you choose this route you’ll quickly run into limitations. If you take the time to learn how to create your scripts, trust me, you’ll never look back!


Automating vSphere is particularly useful for countless applications and the best way is through PowerCLI – a version of PowerShell developed specifically for VMware. Learn how to develop your own PowerCLI scripts with this free 100+ page eBook from Altaro, PowerCLI: The Aspiring Automator’s Guide.

Written by VMware vExpert Xavier Avrillier, this eBook presents a use-case approach to learning how to automate tasks in vSphere environments using PowerCLI. We start by covering the basics of installation, set up, and an overview of PowerCLI terms. From there we move into scripting logic and script building with step-by-step instructions of truly useful custom scripts, including how to retrieve data on vSphere objects; display VM performance metrics; how to build HTML reports and schedule them; the basics on building functions; and more!

Stop looking at scripts online in envy because you wish you could build your own scripts.

Get started on your path to automation greatness – Download the eBook now!

List all VM sizes in Microsoft Azure per Location

Sometimes it’s realy useful to list all the different VM sizes in Microsoft Azure for one Location, for example ‘West Europe’. You can see for example: the VM size, the number of cores, Memory, Max disk count, OS disk size, Resource disk size, etc.

Very powerful to have an overview when choosing the right virtual machine within Microsoft Azure IaaS.

## Login to your subscription using PowerShell
## List all VM sizes in Location 'West Europe'
Get-AzureRmVMSize -Location 'West Europe'


Microsoft Ignite 2016 Slidedeck and Video downloader


Have you missed the Microsoft Ignite 2016 event… problem!! MVP Michel de Rooij has created a script to download all the content (videos and slidedecks). So you can watch all the content again.

This script will download all the Ignite 2016 slidedecks and videos that are available from Techcommunity via the OneDrive URL on the session page. Video downloads will leverage a utility which can be downloaded from, and put it in the same folder as the script. The script itself will try to download the utility when the utility is not present.

Special credits goes to:
Original scraper for slidedecks by Mattias Fors,
Adjusted for video downloading by Michel de Rooij,
Enhancements by Scott Ladewig

Download the script here.



How to: Resize hard disk in Azure Resource Manager (ARM)

Resizing a virtual hard disk in Azure Resource Manager is really easy to do through the Azure Managent Portal. In a few clicks you can extend the virtual hard disk size. Note that the VM should be turned off!! So you need to plan a maintenance window!!
You can also extend the virtual hard disk with PowerShell. In this example I’ve extended the data disk from 25 to 30 GB.

# Specify the VM
$VM = Get-AzureRmVM -ResourceGroupName MSS-DEMO -VMName MSS-DEMO-DC01
# Set the new size of the data disk
Set-AzureRmVMDataDisk -VM $VM -Name MSS-DEMO-DC01-20160801-100246 -DiskSizeInGB 30
# View the new size of the data disk(s)
# Update the configuration in Azure
Update-AzureRmVM -VM $VM -ResourceGroupName MSS-DEMO

2016-08-01_10h31_33    2016-08-01_09h45_27    2016-08-01_10h11_55

2016-08-01_10h12_18    2016-08-01_10h25_33    2016-08-01_10h25_49

2016-08-01_10h31_15     2016-08-01_10h32_11    2016-08-01_10h33_23

1.) Login to the Azure Management Portal
2.) Check the current size of the data disk. In my example 25 GB
3.) Start PowerShell and login to your Azure subscription
4.) Change the data disk to the new value
5.) Update the configuration to Azure
6.) Check the new size of the data disk with PowerShell or within the Azure Management Portal.
In my example the new size is 30 GB.