<# .SYNOPSIS Function gets VMs that have memory limits configured. .DESCRIPTION Takes a list of vms input from Get-VM and checks each one for a configured memory limit .PARAMETER vms The vm(s) to check for memory limits .EXAMPLE Get-VM | Get-VMWithMemLimit .EXAMPLE $vms = Get-VM Get-VMWithMemLimit -vms $vms #> Function Get-VMWithMemLimit { [CmdletBinding()] Param( [Parameter(Mandatory=$True,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True)]$vms ) Begin { $list = @() } Process { $vms | % { $res = $_ | Get-VMResourceConfiguration | Select MemLimitMB if ($res.MemLimitMB -ne "-1") { $item = "" | Select Name,MemoryMB,MemLimitMB $item.Name = $_.Name $item.MemoryMB = $_.MemoryMB $item.MemLimitMB = $res.MemLimitMB $list += $item } } } End { return $list } } <# .SYNOPSIS Removes the memory limit configured on a VM. .DESCRIPTION Takes a list of vms as input from Get-VM and removes the memory limit from each one .PARAMETER vms List of VMs to remove limit from .EXAMPLE Get-VM | Remove-VMMemLimit .EXAMPLE Get-VMWithMemLimit | Remove-VMMemLimit #> Function Remove-VMMemLimit { [CmdletBinding()] Param( [Parameter(Mandatory=$True,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True)]$vm ) Begin { } Process { $vm | % { $spec = new-object VMware.Vim.VirtualMachineConfigSpec $spec.MemoryAllocation = New-Object VMware.Vim.ResourceAllocationInfo $spec.MemoryAllocation.Limit = -1 $vm = get-view -ViewType VirtualMachine -Filter @{"Name"=$_.Name} $vm.ReconfigVM_Task($spec) } } }