Last active
May 9, 2019 16:43
-
-
Save simonjgreen/56999be003ccb686abd3e469e6057757 to your computer and use it in GitHub Desktop.
Set's IOPS, as a filter, in PowerCLI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filter Set-IOPSLimit { | |
$_ | % { | |
$DiskLimitIOPerSecond = 300 | |
# $DiskLimitIOPerSecond = -1 # Unlimited | |
$vm = Get-VM -Name $_.Name | |
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec | |
$vm.ExtensionData.Config.Hardware.Device | | |
where {$_ -is [VMware.Vim.VirtualDisk]} | %{ | |
$dev = New-Object VMware.Vim.VirtualDeviceConfigSpec | |
$dev.Operation = "edit" | |
$dev.Device = $_ | |
$dev.Device.StorageIOAllocation.Limit = $DiskLimitIOPerSecond | |
$spec.DeviceChange += $dev | |
} | |
$vm.ExtensionData.ReconfigVM_Task($spec) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment