Wednesday Tidbit: Automate VMware OSOT for your VDI Images

The other day I tweeted a short bit of code on how to automate the zeroing-out of your VDI images using SDelete:

I got quite a few DMs afterwards asking if it was possible to do the same with VMware’s OS Optimization Tool.

So without further ado, here’s the code I use as the last step in my Packer builds before closing them down for svMotioning:


$ErrorActionPreference = "Stop"
$webserver = "webserver.contoso.local"
$url = "http://" + $webserver
$files = @("VMwareOSOptimizationTool.exe","VMwareOSOptimizationTool.exe.config","my_osot.xml")
$exe = $files[0]
$arg = "-o -t " + $files[2]
# Verify connectivity
if (Test-Connection $webserver Quiet){
# Get the OSOT files
ForEach ($file in $files)
{
Invoke-WebRequest Uri ($url + "/" + $file) OutFile $env:TEMP\$file
}
} else {
throw "No connection to server. Aborting."
}
# Change to temp folder
Set-Location $env:TEMP
# Run OSOT
Try
{
Start-Process $exe ArgumentList $arg Passthru Wait ErrorAction stop
}
Catch
{
Write-Error "Failed to run OSOT"
Write-Error $_.Exception
Exit -1
}
# Delete files
ForEach ($file in $files)
{
Remove-Item Path $env:TEMP\$file Confirm:$false
}

view raw

osot.ps1

hosted with ❤ by GitHub

Please remember to swap out your web server and to specify your own XML file. You could also YOLO it and use one of the built-in templates…

Bill OReilly Well Do It Live GIF - BillOReilly WellDoItLive Mad GIFs

…but don’t be surprised when you cripple half your apps 🙂

Wednesday Tidbit: PowerShell’s Import-PFXCertificate Removes the Private Key

I’ve been working on a complex automation solution recently in lab, and one task was to import a certificate to be used by VMware Horizon.

Those familiar with Horizon will know that any certificate used will need to have its corresponding private key which will also need to be exportable. The certificate also needs to have a friendly name of “vdm”. Continue reading

Wednesday Tidbit: Adding the SQL Server Agent to a Windows Failover Cluster

20150916 - 1Yesterday I decided it was time to patch my VMware vCenter 5.5 hosts to the recently released Update 3. As I make use of properly configured SSL certificates, each component (SSO, Web Client, Inventory and vCenter Server) has to be installed separately. However when I came to install the last one, I ran into an issue. Continue reading

Wednesday Tidbit: Using Cluster-Aware Updating to patch a Windows Server 2012 R2 Failover Cluster

20150820 - 1Recently I built a Windows Server 2012 R2 Failover Cluster to run my SQL, file services and Certificate Authority workloads. For a number of reasons (mentioned in the article) I decided to build it on the Server Core edition of Windows.

Whilst this offers numerous advantages, simplicity isn’t always one of them. One example of this is patching. Continue reading

Building an advanced lab using VMware vRealize Automation – Part 7: Configure vCenter Server Appliance SSL certificates

20150630 - vRAIn part 6 we installed and configured a vCenter Server Appliance in the lab.  This will manage the various components, plus serve as an endpoint for vRealize Automation.

In this post we replace the default SSL certificates from the vCSA with trusted certificates from our in-house certificate authority. Continue reading