Skip to content

Instantly share code, notes, and snippets.

@midacts
Last active April 12, 2017 05:40
Show Gist options
  • Save midacts/b010caa61489bd31636dfae3a0f63ebc to your computer and use it in GitHub Desktop.
Save midacts/b010caa61489bd31636dfae3a0f63ebc to your computer and use it in GitHub Desktop.
# Test file for the Vester module - https://github.com/WahlNetwork/Vester
# Called via Invoke-Pester VesterTemplate.Tests.ps1
# Test title, e.g. 'DNS Servers'
$Title = 'CPU Limit'
# Test description: How New-VesterConfig explains this value to the user
$Description = 'Specify a VM CPU limit'
# The config entry stating the desired values
$Desired = $cfg.vm.cpulimit
# The test value's data type, to help with conversion: bool/string/int
$Type = 'int'
# The command(s) to pull the actual value for comparison
# $Object will scope to the folder this test is in (Cluster, Host, etc.)
[ScriptBlock]$Actual = {
$Object.ExtensionData.Config.CPUAllocation.Limit
}
# The command(s) to match the environment to the config
# Use $Object to help filter, and $Desired to set the correct value
[ScriptBlock]$Fix = {
If ($Desired -eq -1)
{
$Object | Get-VMResourceConfiguration | Set-VMResourceConfiguration -CPULimitMhz $NULL
}
Else
{
$Object | Get-VMResourceConfiguration | Set-VMResourceConfiguration -CPULimitMhz $Desired
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment