Hiya Luc
No that was there just not in the snippy.
On a fresh day with fresh eyes i spotted one typo which was of course it..
I knew this code worked on the previous environment however now for the real reason i wanted to post here in the first place.
Having exported to JSON for the Values
CPUReservation
CPULimits
MemReservation
Mem Limits
I want to be reapplying the settings from the JSON back up to the original VM
-- My code changes the CPU\Mem Reservations just fine but fails to set the value back for Limits.
-(Where the value should be "Unlimited and in the JSON file it is shown to be as -1)
Code is below.
$OriginalVMSettings = Get-Content -Raw -Path ".\LSVMOriginalSettings.json" | ConvertFrom-Json
foreach ($LSVM in $OriginalVMSettings)
{
Write-Output $LSVM.Name
$CurrentVM = Get-VM -Name $LSVM.VMName
$CurrentVMResConfig = $CurrentVM | Get-VMResourceConfiguration
Write-Output $CurrentVMResConfig
$CurrentVMResConfig | Set-VMResourceConfiguration -CpuReservationMhz $LSVM.CPUReservationMHz `
$CurrentVMResConfig | Set-VMResourceConfiguration -CpuLimitMhz $LSVM.CPULimitMhz `
$CurrentVMResConfig | Set-VMResourceConfiguration -MemReservationMB $LSVM.MemReservationMB `
$CurrentVMResConfig | Set-VMResourceConfiguration -MemLimitMB $LSVM.MemLimitMB
Write-Output "After restoration..."
$CurrentVM | Get-VMResourceConfiguration
}