Hi Guys
I am am about to set the memory limit of all my virtual machines in a datacenter to Unlimited.
With this: (pretty easy)
Get-Datacenter -name "Target Datacenter" | Get-Cluster | Get-VM | Get-VMResourceConfiguration | where {$_.MemLimitMB -ne "-1"} | Set-VMResourceConfiguration -MemLimitMB $null
But don't really know how to approach the reverse.
$Details
$SettingsVM
$Details = Get-Datacenter -name "Target Datacenter" | Get-Cluster | Get-VM | Select Name,MemoryMB
$SettingsVM.Name = $Details.Name
$SettingsVM.MemoryMB = $Details.MemoryMB
Get-VM -name $SettingsVM.Name | Get-VMResourceConfiguration | where {$_.MemLimitMB -eq $Null} | Set-VMResourceConfiguration -MemLimitMB $Details.MemoryMB
Thanks
John
Hi John,
you can use the next PowerCLI script for the reverse approach:
Get-Datacenter -name "Target Datacenter" |
Get-VM |
ForEach-Object {
$VM = $_
$VM | Get-VMResourceConfiguration |
Where-Object {$_.MemLimitMB -eq -1} |
Set-VMResourceConfiguration -MemLimitMB $VM.MemoryMB
}
Hi John,
you can use the next PowerCLI script for the reverse approach:
Get-Datacenter -name "Target Datacenter" |
Get-VM |
ForEach-Object {
$VM = $_
$VM | Get-VMResourceConfiguration |
Where-Object {$_.MemLimitMB -eq -1} |
Set-VMResourceConfiguration -MemLimitMB $VM.MemoryMB
}
Thanks RvdNieuwendijk, That is so much cleaner than what I was trying to do.
