You dont have javascript enabled! Please enable it! How To Set Hyper-V Storage Quality Of Service (QoS) On All Virtual Hard Disks Via PowerShell? #HyperV #PowerShell - CHARBEL NEMNOM - MVP | MCT | CCSP | CISM - Cloud & CyberSecurity

How to Set Hyper-V Storage Quality of Service (QoS) on all Virtual Hard Disks via PowerShell? #HyperV #PowerShell

4 Min. Read

Hello folks,

As we are approaching the holidays, and being busy preparing for the new year! I would like to share with you a nifty PowerShell tool to set Hyper-V storage Quality of Service (QoS).

Hyper-V Storage QoS!

Killer feature… Microsoft introduced in Windows Server 2012 R2, Hyper-V storage Quality of Service (QoS). Storage QoS enables you to manage storage throughput for virtual hard disks that are accessed by your virtual machines.

Storage QoS enables you to specify the maximum and minimum I/O loads in terms of I/O operations per second (IOPS) for each virtual disk in your virtual machines. Minimum and maximum IOPS are measured in 8 KB increments,

Now If you are concerned about a specific virtual hard disk for a particular VM is not receiving sufficient disk I/O, then you can set a minimum IOPS level. Remember that minimum is a soft reserve (best effort) which means it might fail but an event will be logged that things are going wrong. On the other hand, if the virtual hard disk is accommodating a very high I/O then you may want to populate the Maximum IOPS field as a way of limiting the total number of IOPS that the virtual hard disk can consume, and ensure that the storage throughput of one virtual hard disk does not impact the performance of another virtual hard disk on the same Hyper-V host.

For more information on what’s new in Storage QoS in Windows Server 2012 R2 or later version, please check the official documentation.

Best Practices: Hyper-V Storage QoS!

If you identify a VM that is using more resources than you want it to use, then you can go ahead and apply a limit to it right away, this is what we call a reactive approach.

To measure a VM, you can use the Measure-VM cmdlet but first, you must enable VMResourceMetering. The virtual machine metrics infrastructure has been extended with storage-related attributes in Windows Server 2012 R2, so you can monitor the performance. To do this Microsoft use what they call “normalized IOPS” where every 8K of data is counted as an I/O.


The reactive approach is not really ideal, because you are reacting since you have a problem.

What I recommend doing is to take a proactive approach earlier.

So as you are deploying your virtual machines, you can start applying a default limit to all individual VM’s VHDs, and then you can raise based on workload demand.

As best practices, consider tiers based on planned usage as Virtual Machines are deployed as the following:

  • VDI VMs: Max 100 IOPs limit
  • General VMs: Max 500 IOPs limit
  • High Performance VMs: > 500 IOPs limit

How can you limit individual VM’s VHD?

The answer is straightforward, the new Storage QoS feature is available under Advanced Features for each individual virtual hard drive as shown in the figure below:


Automation: Hyper-V Storage QoS!

Now the challenging question is what if you have hundreds of VMs already deployed and you need to start using the proactive approach?

The answer is simple, open each VM settings and limit the maximum IOPs to 500.

And what if each VM has 4 virtual hard disks attached to it? so 400 VHDs.

The answer is PowerShell of course!

I created the following tool script that will help you to limit all individual VM’s VHDs to a default IO number you specify.


Set Storage Quality of Service for all Virtual Machines.

Set Minimum and Maximum Storage Quality of Service for all Virtual Machines.
File Name : Set-VMStorageIO.ps1
Author    : Charbel Nemnom
Version   : 1.1
Requires  : PowerShell Version 4.0 or above
OS        : Windows Server 2012 R2 Hyper-V or Free Hyper-V Server 2012 R2

To provide feedback or for further assistance please visit:

The name of a single Hyper-V Server
Switch to disable Storage QoS
The storage QoS to be set - Maximum, Minimum or Both
The Storage minimum limit IO number to be set
The Storage maximum limit IO number to be set

.\Set-VMStorageIO -HVServerName <HyperVServerName> -MinMax <Maximum> -StorageMaxIO <500>
This example will set the maximum Storage QoS for all virtual machines to 500.
.\Set-VMStorageIO -HVServerName <HyperVServerName> -MinMax <Minimum> -StorageMinIO <250>
This example will set the minimum Storage QoS for all virtual machines to 250.
.\Set-VMStorageIO -HVServerName <HyperVServerName> -MinMax <Both> -StorageMinIO <250> -StorageMaxIO <1000>
This example will set the Storage QoS for minimum 250 IOPS and maximum 1000 IOPS for all virtual machines.
.\Set-VMStorageIO -HVServerName <HyperVServerName> -Disable
This example will disable the Storage QoS for all virtual machines.

param (
    [Parameter(Mandatory = $true, Position = 0, HelpMessage = 'Hyper-V Server Name')]
    [Alias('Hyper-V Server')]
    [Parameter(HelpMessage = 'Disable Storage QoS', ParameterSetName = "Disable")]
    [Parameter(Mandatory = $true, HelpMessage = 'Maximun, Minimum or Both', ParameterSetName = "Enable")]
    [ValidateSet("Maximum", "Minimum", "Both")]
    [String]$MinMax = "Maximum",
    [Parameter(HelpMessage = 'Storage Minimum IO', ParameterSetName = "Enable")]
    [Parameter(HelpMessage = 'Storage Maximum IO', ParameterSetName = "Enable")]

# If Disable switch equal to true, disable Storage QoS on all VMs
If ($Disable) {
    $VMIOPs = Get-VM -ComputerName $HVServerName | Get-VMHardDiskDrive
    foreach ($VM in $VMIOPs) {
        Set-VMHardDiskDrive -ComputerName $HVServerName -VMName $VM.VMName -ControllerType $VM.ControllerType -ControllerNumber $VM.ControllerNumber -ControllerLocation $VM.ControllerLocation -MinimumIOPS $false -MaximumIOPS $false
} else {
    If ($StorageMinIO -eq '0' -and $StorageMaxIO -eq '0') {
        Write-Error "Minimum and Maximum IOPs cannot both be set to Zero!"
    If ($StorageMinIO -gt $StorageMaxIO) {
        Write-Error "The maximum IOPS must be equal to or greater than the minimum IOPS or set to zero to accept the system default value!"
    $VMIOPs = Get-VM -ComputerName $HVServerName | Get-VMHardDiskDrive
    If ($MinMax -eq "Maximum") {
        foreach ($VM in $VMIOPs) {
            Set-VMHardDiskDrive -ComputerName $HVServerName -VMName $VM.VMName -ControllerType $VM.ControllerType -ControllerNumber $VM.ControllerNumber -ControllerLocation $VM.ControllerLocation -MaximumIOPS $StorageMaxIO
    } elseif ($MinMax -eq "Minimum") {
        foreach ($VM in $VMIOPs) {
            Set-VMHardDiskDrive -ComputerName $HVServerName -VMName $VM.VMName -ControllerType $VM.ControllerType -ControllerNumber $VM.ControllerNumber -ControllerLocation $VM.ControllerLocation -MinimumIOPS $StorageMinIO
    } else {
        foreach ($VM in $VMIOPs) {
            Set-VMHardDiskDrive -ComputerName $HVServerName -VMName $VM.VMName -ControllerType $VM.ControllerType -ControllerNumber $VM.ControllerNumber -ControllerLocation $VM.ControllerLocation -MinimumIOPS $StorageMinIO -MaximumIOPS $StorageMaxIO
# End

Here you so go Hyper-V storage QoS Maximum IOPs is set for all virtual machines, I feel it’s much easier than having to set the limit individually for each VM’s VHD.


If you have more scenarios, please feel free to leave a comment below:

Demo: Hyper-V Storage QoS!

Would you like to see Hyper-V Storage QoS in action? Then make sure to watch this short demo:

And now It’s time to sign off and prepare for the holidays… Airplane


Enjoy the holidays… Party smile


Photo of author
About the Author
Charbel Nemnom
Charbel Nemnom is a Senior Cloud Architect with 21+ years of IT experience. As a Swiss Certified Information Security Manager (ISM), CCSP, CISM, Microsoft MVP, and MCT, he excels in optimizing mission-critical enterprise systems. His extensive practical knowledge spans complex system design, network architecture, business continuity, and cloud security, establishing him as an authoritative and trustworthy expert in the field. Charbel frequently writes about Cloud, Cybersecurity, and IT Certifications.

FREE Guide: The Journey of a System Center Consultant Implementing BSM #Savision #SysCtr

Enjoying The End of Year 2014 With Last Microsoft Exams #Microsoft #MCS #MCSA #O365 #Azure


Let us know what you think, or ask a question...