Sorry for the delay, just now getting caught up on some old emails and found the one for this thread. The script below is meant to be run interactively after you've already connected to vCenter and it expects you to provide a cluster name to it. I did that because our environment is pretty large and I didn't want to hit it all at once, though it really shouldn't be an issue (other than the amount of time it takes). You can easily tweak it to just run on every VM. The script not only sets the memory limit on all VMs to the default (unlimited) but also resets the shares and reservations back to default as well as the same three values for CPUs. The script isn't as optimized as it could be for speed (this is one of my first PowerCLI scripts, so it is old) and could probably have some disk I/O resource/share items added to it. Regardless, here it is:
Param([string]$strClusterName)
if (! $strClusterName) {
Write-Output ("")
Write-Output ("Hey, you need to give me a parameter!")
Write-Output (" Example: " + $MyInvocation.MyCommand.Name + " <ClusterName>")
Write-Output (" - where <ClusterName> is a string that matches the name of your VM cluster")
Write-Output ("")
}
else {
Write-Output ("")
Write-Output ("Thinking...")
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec;
$spec.cpuAllocation = New-Object VMware.Vim.ResourceAllocationInfo;
$spec.cpuAllocation.Shares = New-Object VMware.Vim.SharesInfo;
$spec.memoryAllocation = New-Object VMware.Vim.ResourceAllocationInfo;
$spec.memoryAllocation.Shares = New-Object VMware.Vim.SharesInfo;
$spec.cpuAllocation.Shares.Level = "normal";
$spec.cpuAllocation.Reservation = 0;
$spec.cpuAllocation.Limit = -1;
$spec.memoryAllocation.Shares.Level = "normal";
$spec.memoryAllocation.Reservation = 0;
$spec.memoryAllocation.Limit = -1;
#Get-Cluster $strClusterName | Get-VM | % {Get-View $_.ID} | % {Get-View($_.ReconfigVM_Task($spec))}
Get-VM | % {Get-View $_.ID} | % {Get-View($_.ReconfigVM_Task($spec))}
}
EDIT:
1) I have no idea why the above script is double-spaced, but I'm too lazy to fix it.
2) I just now noticed that this is my modified version that was set to run on ALL VMs in the vCenter you are connected to. The second to last line (Get-VM ...) really should be commented out and the one above it should be uncommented to run as I originally intended it.