Release date: January 15th 2023
Welcome to my VMware Dynamic Environment Manager series. In this session I will describe how I upgraded the VMware DEM Application Profiler to v. 2212. As I use my Application Capture VM for this, I make sure to do this upgrade together with the App Volumes Tools.
I have previously shown how to do this manually, but as I try to automate as many repetitive tasks as possible, I have now created the PowerShell script below, to do this for me.
I start out by downloading the installation media from VMware Customer Connect
The script workflow is as follows.
Before I can run the script below, I have to create both vCenter and WinRM credentials:
- vCenter admin-user:
New-VICredentialStoreItem -User <user> -Password <user> -Host <server> -File C:\<your location.xml>
- WinRM admin-user:
$credential = Get-Credential
$credential | Export-CliXml -Path '<path>\WinRM_admin.xml'
Now that I have the credentials ready, I am good to go. (PS: I know I’m no programmer and a lot of this script have the potential for improvement, but this gets the job done, and that’s good enough for me).
appvtools-demprof-upgr.ps1
# --- Initialize PowerCLI Modules ---
Import-Module VMware.VimAutomation.Core
Import-Module VMware.VimAutomation.Common
Set-PowerCLIConfiguration -Scope User -ParticipateInCeip $false -Confirm:$false
Set-PowerCLIConfiguration -InvalidCertificateAction ignore -Confirm:$false
Set-PowerCLIConfiguration -DefaultVIServerMode Multiple -Confirm:$false
# --- Connect to vCenter with Get-VICredentialStoreItem ---
$viserver = "vCenter fqdn"
$viuser = Get-VICredentialStoreItem -File "<path to vCenter Credentials>.xml" -host $viserver
Connect-viserver -Server $viserver -User $viuser.user -Password $viuser.password
# --- Revert Capture VM to Pre-Capture Snapshot and power on ---
$CaptureVM = "<Capture VM Name>"
$Snapshot = "Pre-AppCapture"
Write-Host "Reverting the Capture VM to the Pre-Capture Snapshot" -ForegroundColor Green
Set-VM -VM $CaptureVM -SnapShot $Snapshot -Confirm:$false
Write-Host "Starting the Capture VM" -ForegroundColor Green
Get-VM -Name $CaptureVM | Start-VM
sleep -Seconds 60 #SLOW LAB :)
# --- Configure PSSession ---
$credential = Import-CliXml -Path "<path to WinRM credentials>\WinRM_admin_${env:USERNAME}_${env:COMPUTERNAME}.xml"
$session = New-PSSession -ComputerName $profilerVM -Credential $credential -Authentication CredSSP
Invoke-Command -Session $session -ScriptBlock {
# --- Variables ---
$InstallDir = "C:\Install\"
$MsiDir = "C:\Install\Msi"
$DemZip = "<network path>\VMware-DEM-Enterprise*.zip"
$DEMProfilerName = "VMware DEM Application Profiler*"
$AppVolToolsName = "App Volumes Tools*"
$ApplogFile = "$msiDir\AppVolTools.log"
$AppvToolsMsi = "<network path>\Installation\Tools\$AppVolToolsName"
# --- Create Temp Folder ---
New-Item -Path $installDir -type directory -Force
New-Item -Path $msiDir -type directory -Force
# --- Extract Dynamic Environment Manager Application Profiler MSI ---
Expand-Archive -Path $DemZip -DestinationPath $InstallDir\DEM
sleep -Seconds 10 #SLOW LAB :)
$DemMsi = Get-Item $installDir\"DEM\Optional Components\*Profiler*x64*.*"
Copy-Item $DemMsi $installDir\msi
# --- Copy App Volumes Tools MSI to msi-folder ---
Copy-Item $AppvToolsMsi $installDir\msi
# --- Define MSI Switches ---
# --- VMware DEM Application Profiler ---
$DemArgs = @(
"/qn"
"/l* InstallProfiler.log"
)
# --- VMware App Volumes Tools ---
$AppvArgs = @(
"/qn"
"REBOOT=Reallysuppress"
)
# --- Install/upgrade DEM Application Profiler ---
Write-Host "Installing / upgrading DEM Application Profiler" -ForegroundColor Green
$DEMProfilerPath = (Get-ChildItem -Path $msiDir | Where-Object {$_.name -like $DEMProfilerName}).Fullname
$DEMProfilerInstall = (Start-Process -Filepath $DEMProfilerPath -ArgumentList $DemArgs -Wait -PassThru)
$DEMProfilerInstall.ExitCode
# --- Install App Volumes Tools ---
Write-Host "Installing / upgrading VMware App Volumes Agent" -ForegroundColor Green
$AppVolPath = (Get-ChildItem -Path $msiDir | Where-Object {$_.name -like $AppVolToolsName}).Fullname
$AppVolToolsInstall = (Start-Process -Filepath $AppVolPath -ArgumentList $AppvArgs -Wait -PassThru)
$AppVolAgentInstall.ExitCode
# --- Tidying up ---
Remove-Item –path $installDir –Recurse -Force
}
Remove-PSSession $session
# --- Shut down VM ---
write-host "Shutting down Capture VM" -ForegroundColor Green
Shutdown-VMGuest -VM $CaptureVM -Confirm:$False
sleep -Seconds 30 #SLOW LAB :)
# --- Remove Snapshot ---
write-host "Removing old Pre-Capture Snapshot" -ForegroundColor Green
Get-VM $CaptureVM | Get-snapshot -Name $snapshot | Remove-Snapshot -Confirm:$false
# --- Take new Snapshot ---
write-host "Creating new Pre-Capture Snapshot" -ForegroundColor Green
Get-VM $CaptureVM | New-Snapshot -Name $snapshot
# --- Diconnect from vCenter ---
write-host "Diconnect from vCenter" -ForegroundColor Green
Disconnect-VIServer -Server $viserver -Confirm:$false
This concludes my session about automating the installation / upgrade of the VMware DEM Application Profiler. Also this concludes my upgrade of the DEM components in my LAB.
Big thanks to Askaresh’s: Script to install VMware EUC Agents – App Volumes Agent, DEM Agent and Horizon Agent
Official VMware Dynamic Environment Manager Documentation
Disclaimer: Every tips/tricks/posting I have published here, is tried and tested in different it-solutions. It is not guaranteed to work everywhere, but is meant as a tip for other users out there. Remember, Google is your friend and don’t be afraid to steal with pride! Feel free to comment below as needed.