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
$envVM =Get-ChileItem env:computername
#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).