The 4th of my 10 demos at TechEd North America 2014 was based on Enhanced Session Mode and all the RemoteFX via the VMBus goodness that it provides admins with when interacting with VMs on WS2012 R2 Hyper-V.
It was a complicated demo to script – but certainly not the most complicated! The logic is:
- Clean up the environment – this involved disabling enhanced session mode (I normally use it)
- Connect to a VM and show the lack of copy/paste etc – note how I directly run VMConnect
- Enable enhanced session mode
- Log into the VM and show off the features of the RemoteFX-powered connect
- Copy/paste etc
- Clean up the demo
Some of things I do in this script are used in some of the later, more complicated demo scripts. You’ll soon see lots more invoke-command, PSEXEC, and process manipulation.
function KillProcess ($Target)
{
$Processes = Get-Process
Foreach ($Process in $Processes)
{
if ($Process.ProcessName -eq $Target)
{
Stop-Process $Process
}
}
}
CLS
$DemoHost1 = "Demo-Host1"
$DemoVM1 = “OOBFileCopy”
$VMConnect = "C:\Windows\system32\vmconnect.exe"
$VMConnectParams = "$DemoHost1 $DemoVM1"
#Prep the demo
KillProcess "vmconnect"
Set-VMHost -EnableEnhancedSessionMode 0 | Out-Null
#Start the demo
Read-Host "Start the demo"
Write-Host "`nThe host is configured as default – same old VMConnect:" -foregroundcolor red -backgroundcolor yellow
Write-Host "`n(Get-VMHost).EnableEnhancedSessionMode"
(Get-VMHost).EnableEnhancedSessionMode | Out-Host
Read-Host "`nConnect to the demo virtual machine"
Start-Process $VMConnect -ArgumentList $VMConnectParams
Read-Host "`nStop VMConnect"
KillProcess "vmconnect"
#Enable enhanced session mode
Read-Host "`nEnabled Enhanced Session Mode"
Write-Host "`nLet’s get the new administrator experience:" -foregroundcolor red -backgroundcolor yellow
Write-Host "`nSet-VMHost -EnableEnhancedSessionMode `$true"
Set-VMHost -EnableEnhancedSessionMode $true | Out-Null
Write-Host "`n(Get-VMHost).EnableEnhancedSessionMode"
(Get-VMHost).EnableEnhancedSessionMode | Out-Host
Read-Host "`nConnect to the demo virtual machine"
Start-Process $VMConnect -ArgumentList $VMConnectParams
Write-Host "`nLog in and demonstrate Enhanced Session Mode" -foregroundcolor red -backgroundcolor yellow
Read-Host "`nEnd the demo"
KillProcess "vmconnect"
Set-VMHost -EnableEnhancedSessionMode 1 | Out-Null