Welcome to the Liquidware Community Site.
Current and Future Clients/Partners are Welcome.

Dynamically Increase VMware session RAM using ProfileUnity

The goal was to increase RAM for specific users within a pool due to work role or requirements. I created a powershell script that uses PowerCLI Set-VM cmdlet to change the VM RAM. By placing a user in a specific AD Group we were able to leverage ProfileUnity Elevated Privileges and Application Launcher settings to initiate the command that was compiled into an EXE. The steps below document the process in more detail.


1)  On the Template image, change the hardware settings to Enable 'Memory Hot Plug'

2)     Power up the template and Install VMware.PowerCLI component on Template image

      Install-Module VMware.PowerCLI -Scope:AllUsers -Force -AllowClobber


3)     Shutdown template, snapshot and recompose Non-Persistent pool


4)     In vSphere create an account with appropriate permissions to modify a Virtual Machine to be used in Powershell/PowerCLI script.


5)     Create a PowerShell script (I used Sapien Tools because I will later compile it into an EXE) (Note: might not be the most efficient or robust code feel free to expand error checking)

#Get Argument from Commandline default to 4GB if nothing passe

parm (

[string]$sizeInGB =4

)

#Set Variables

$envVM =Get-ChileItem env:computername

$vm=$envVM.value

#import modules

Import-Module VMware.PowerCLI

#Setup PowerCLI Environment

Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -ParticipateInCeip $false -Confirm $false

#Connect to VirtualCenter

Connect-viserver -server <vcenter name> -Username '<account with perms to modify>' -Password 'password' -ErrorAction Stop

#Check to determine VM Available before attempting to change RAM setting

Get-VM $VM -ErrorAction Stop

$Set the VM's memory in GB, also update Notes field in vSphere to reflect the change was done dynamically

Set-VM -vm $VM -memoryGB $sizeInGB -notes "Dynamic increase to $sizeInGB GB" -Confirm:$false


6)     Compile the script into an EXE (sure there are other ways to do it, but don’t want the password to be clear text).


7)     In ProfileUnity create a Filter Management to target the Dynamic RAM increase. In my case I created 3 different groups (6GB, 8GB, 12GB)


8)     In ProfileUnity Configuration Management click on Privilege Elevation and create a new privilege elevation rule for each Group (or you could nest the groups into another Filter Management group within ProfileUnity if you like that method better).

9)     In ProfileUnity go to Application Launchers and create a new application launcher rule. In this example I am sending the argument of 6 to the script which will increase it to 6GB of memory. Likewise I have 8GB and 12GB application launcher rules.

10)  Update the Configuration file and deploy to your share.

11) After login you should see it update in vSphere (Memory and Notes).

Comments

  • This is an AWESOME write up!!! BUT!! Be careful with this automated upgrade of memory! You need to make sure your host hypervisor has the memory to accept this. Recommend some sort of approval process from IT. You can run a hypervisor out of resources real quick if an application goes nuts on 100 machines without some checks and balances.

    Your ProfileUnity filters are driving it based on AD Group membership. That is great. But you need to trend the user to make sure they actually need that memory all the time and that the Hypervisor Host can support it.

    BUT.... Again this is a great use case... Love it!!

  • Thanks for the comment Chris. The AD groups are locked down so only 4 of us can move people in and out of the groups to avoid over subscribing RAM. We also use ControlUp with Insights (another great product @ great price) to check on recommendations for RAM and CPU--also used to look at past 30 days activity to see if it is warranted before we add a user to a specific group.

Sign In or Register to comment.