Importance to set Dynamic Memory Maximum in Hyper-V 2012
In my little lab it was quite the time to do an rearm of the servers licenses as I had installed them with the evaluation version. This can be done with the slmgr.vbs /rearm command and a reboot.
And when I came to the second server where the domain controller resides I noticed that it consumed a lot of memory for just having the DC role.
When looking a bit closer I noticed sessions where me and a colleague that have been logged in but in disconnected mode and consumed both CPU and memory. In almost every server this is not optimal where Admins can stay logged in forever and this can be handled with a GPO setting to restrict the time for a disconnected session on servers residing in a specific OU.
Another problem was that when I created the DC VM I just activated the Dynamic memory without setting any limits and this could cause a host with no physical memory left and VM´s going crazy with allocated memory. Setting the Startup memory is important but also setting the Maximum RAM, I have as a best practice to set the startup and Maximum to the same values.
With PowerShell I easily could change the settings of the VM to have a more reasonable maximum value than 1TB. And as you can see with the -PassThrough parameter I can do it in one line.
PS C:\> get-vm dc01 | Stop-VM -Passthru | Set-VM -MemoryMaximumBytes 2GB -Passthru | Start-VM
And after the DC restarted you can see that it only consumes 624 MB RAM.
i need power shell script in Add RAM to VM