After deploying my latest horizon lab, I hit an issue where I could not hit the login page to authenticate for a Horizon desktop using BLAST, I would be greeted by the following message:
Failed to Connect to Connection Server
I pulled my hair out for a few minutes, before I realised I’ve hit this issue before, and the fix is quite simple.
Below is the VDI Cleanup script that I’ve been using over the years. I thought I’d post this after setting up a Horizon Lab environment. I shared it earlier in the year on Reddit, and had some good suggestions which I used to update the script. The script has been taken from other blogs over the years and just edited further and further for my own/customers needs.
REM ************************************************
REM Stopping and disabling Windows Telemetry service
REM ************************************************
sc stop DiagTrack
sc config DiagTrack start= disabled
sc stop dmwappushservice
sc config dmwappushservice start= disabled
REM *********************
REM Stop and disable Windows update service
REM *********************
sc stop wuauserv
sc config wuauserv start= disabled
REM *********************
REM Delete any existing shadow copies
REM *********************
vssadmin delete shadows /All /Quiet
REM *********************
REM delete files in c:\Windows\SoftwareDistribution\Download\
REM *********************
del c:\Windows\SoftwareDistribution\Download\*.* /f /s /q
REM *********************
REM delete hidden install files
REM *********************
del %windir%\$NT* /f /s /q /a:h
REM *********************
REM delete prefetch files
REM *********************
del c:\Windows\Prefetch\*.* /f /s /q
REM *********************
REM Update OEM Information with Build Date
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation /v Model /d "Build %DATE%" /t REG_EXPAND_SZ /f
REM *********************
REM Run Disk Cleanup to remove temp files, empty recycle bin
REM and remove other unneeded files
REM Note: Makes sure to run c:\windows\system32\cleanmgr /sageset:1 command
REM on your initially created parent image and check all the boxes
REM of items you want to delete
REM *********************
c:\windows\system32\cleanmgr /sagerun:1
REM ********************
REM Defragment the VM disk
REM ********************
sc config defragsvc start= auto
net start defragsvc
defrag c: /U /V
net stop defragsvc
sc config defragsvc start = disabled
REM *********************
REM Clear all event logs
REM *********************
wevtutil el 1>cleaneventlog.txt
for /f %%x in (cleaneventlog.txt) do wevtutil cl %%x
del cleaneventlog.txt
REM *********************
REM release IP address
REM *********************
ipconfig /release
REM *********************
REM Flush DNS
REM *********************
ipconfig /flushdns
REM *********************
REM Shutdown VM
REM *********************
shutdown /s /t 0
The best news about this release is the “easy installer“, which also allows you to migrate from older versions. In this post, I’ve documented the screenshots in steps for you, as I know many of you out there like to see the end to end process before you undergo an update yourself, so you know what to expect.
During this migration process the following will happen;
New LCM virtual appliance deployed
New IDM appliance deployed (unless you select to link to an existing environment)
Existing LCM settings and content will be migrated
In this blog post, I am going to break down a PowerShell code I have created (with help from some colleagues). The functions of this PowerShell code are;
Present a GUI form to the end user
Connect to a vCenter
Select the virtual machine to be cloned
Select the datastore the new VM is to be stored on (display DS free space)
Select the host for this VM to be created against (display free memory on the host)
Set the new VM name
Create an IP reservation in both the Production and DR DHCP Scopes
Below are some functional screenshots of the code’s GUI and also a rough flowchart of what I needed to achieve.
You can skip to the end to find the full code or my github.
TAM Lab Recording
Since posting this blog, I also covered this in a VMware TAM Lab recording which you can watch below.
A little more background on the script
So my customer had a dedicated environment for hosting their custom application, however these applications were built and running inside an old unsupported OS which expected to be running on a particular era of CPU’s to run correctly, for example todays Intel Skylake would cause the OS to panic and not run. As you can also imagine with this type of older OS, there are no VM Tools support either.
Here is the architecture diagram;
Providing DR around this environment was interesting, we could protect the VM using SRM and storage array LUN replication. But this also presented some issues, when the VM boots in DR. “what happens with networking?” hence we setup a DHCP reservation on both Production and DR. Meaning we know the VMs IP regardless of where its booted.