Virtually Sober

If there is free booze and Virtualization; I'm there!

Upgrading your home lab to 10GbE on the cheap!

Since building my hyperconverged home lab in Jan 2015 and finally sharing it on my blog Jan 2017 it has quickly become the most popular blog post by quite a margin. But one thing has always bothered me about the lab, with 1 SSD per ESXi host, and that’s the connectivity. Stuck in the slow lane at 1GbE it was always the limiting factor when configuring replication between hosts with Zerto and performing an initial sync. This was made even worse when I wanted to plug in a Rubrik r344 appliance (Supermicro 4 node server with 4 x 10GbE cards) because no matter how fast Rubrik can ingest the backup and live mount it back over NFS, 1GbE is as fast as it will go. Demonstrating live mounts over 1GbE certainly works, but it’s not the same wow factor as it is with 10GbE.

Something had to give. Do I build a new lab using motherboards with built-in 10GBase-T NICs? Read more of this post

Automatically Updating To PowerCLI 6.5.1

I’m blogging live from the Boston Summer VMUG Usercon 2017 where I’m sharing my top 10 PowerShell tips and tricks. A big topic at the show, for anyone interested in PowerShell and PowerCLI, is the change with PowerCLI 6.5.1 in how you install, update and load it. This is pretty important because all your scripts are going to need updating! Otherwise, they will potentially stop working if you are about to or have already upgraded to vSphere 6.5.x. There’s no reason that I’m aware of that you can’t upgrade in advance and still interact with vSphere 6.0 etc. So now is as good as time as any to start planning your upgrade.

Before PowerCLI 6.5.1 you would’ve used this at the start of each script:

Add-PSSnapin VMware.VimAutomation.Core

If you attempt this command on a computer running PowerCLI 6.5.1 it will result in a lovely “The Windows PowerShell snap-in ‘VMware.VimAutomation.Core’ is not installed on this computer.” error:

 

From now on you need to use:

Import-Module VMware.PowerCLI

But wait, you can’t just start using this new command otherwise you will get another error “The specified module ‘VMware.PowerCLI’ was not loaded because no valid module file was found in any module directory.”:

PSSnapInError

You’ll first need to uninstall your current version of PowerCLI from Programs and Features, download the PowerCLI module from the PSGallery then save a copy for future offline use (if needed). While this is certainly much easier than before, it still sounds awfully manual to me! To save you time and effort why not use PowerShell to automate this process? Here is a simple script I wrote to do just that:

#######################
# Configure the variable below
#######################
# Specify a directory to download and install the new PowerCLI module to for future offline access
$PSModulePath = "c:\PowerCLIModule\"
#####################################################################
# Nothing to change below this line, commented throughout to explain
#####################################################################
#######################
# Testing if PS Module path exists, if not creating it
#######################
$PSModulePathTest = test-path $PSModulePath
if ($PSModulePathTest -eq $False)
{
New-Item -ItemType Directory -Force -Path $PSModulePath
}
#######################
# Checking to see if PowerCLI is installed in Program Files, takes 5-30 seconds
#######################
write-host "Checking if PowerCLI is installed in Program Files, wait 5-30 seconds"
$PowerCLIInstalled = Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -eq "VMware vSphere PowerCLI"}
#######################
# If PowerCLI is installed then removing it, so we can run from the module instead
#######################
if ($PowerCLIInstalled -ne $null)
{
write-host "PowerCLI Installed - Uninstalling to allow for new PowerCLI module"
# Uninstalling PS module
$PowerCLIUninstall = $PowerCLIInstalled.Uninstall()
# Checking return value for success
$PowerCLIUninstallValue = $PowerCLIUninstall.ReturnValue
if ($PowerCLIUninstallValue -ne 0)
{
write-host "Uninstall Of PowerCLI Failed - Most likely due to not running as administrator"
}
# Finished uninstall
}
#######################
# Checking to see if the PowerCLI module is already installed
#######################
$PowerCLIModuleCheck = Get-Module -ListAvailable VMware.PowerCLI
#######################
# If PowerCLI module is not installed, nothing found, then running install...
#######################
if ($PowerCLIModuleCheck -eq $null)
{
write-host "PowerCLI Module Not Found - Installing"
# Not installed, finding module online
Find-Module -Name VMware.PowerCLI
# Trusting PS Gallery to remove prompt on install
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
# Installing module
Install-Module -Name VMware.PowerCLI –Scope AllUsers -Confirm:$false
# If running this is a repeat demo/test, you can uninstall the module using the below:
# Uninstall-Module -Name VMware.PowerCLI -Confirm:$false
# Saving to folder
Save-Module -Name VMware.PowerCLI -Path $PSModulePath
}
#######################
# Testing import of PowerCLI module
#######################
Import-Module VMware.PowerCLI
Try
{
$PowerCLICommandTest = Get-VICommand
$PowerCLIImportTest = $True
}
Catch
{
$PowerCLIImportTest = $False
}
#######################
# Outputting result
#######################
if ($PowerCLIImportTest -eq $True)
{
write-host "New PowerCLI Module Successfully Installed"
}
else
{
write-host "Something went wrong! Maybe you, maybe me. Does this computer have internet access and did you run as administrator?"
}
#######################
# End of script
#######################

Make sure your computer has internet access and you are running the script as administrator, otherwise you can’t download the latest version, uninstall the old or import the module for all users. You can download the full example from here:

AutoUpdatingToPowerCLI6.5.1.zip

Going forward you can now update your PowerCLI version with minimal fuss using:

Update-Module -Name VMware.PowerCLI

If you found this useful please like and share. Happy scripting,

Joshua

See you next week at ZertoCON 2017!

Hi all,

Just a quick Friday update to say that I’ll be at ZertoCON next week as a blogger to catch up on all the latest things Zerto, attend some interesting sessions I have penciled in, and to catch the cool keynote from General Michael Hayden! And of course, there ain’t no party like a Zerto party! If you see me walking around feel free to grab me to talk about any scripts you have ideas for, as I’m always on the hunt for requests.

ZertoCON2017

If you haven’t already registered for the biggest virtualization event on the East Coast (are you crazy?!) then you still have time:

http://www.zerto.com/zertocon/

Tip: use the code ZHALF17 at checkout for a tasty last minute 50% discount.

Have a great weekend and hope to see you at ZertoCON 2017,

Joshua

Scripting a Rubrik Recovery Plan using REST APIs & PowerShell

Following hot on the heels of my first post on an “Introduction to Rubrik REST APIs using PowerShell & Swagger” I’d now like to show you how to easily automate the recovery and boot ordering of VMs as a Recovery Plan.

In the Rubrik HTML5 interface, you can easily recover any VM in just a few clicks with the VMs running on a whopping 30,000 IOPS per brik (Rubrik appliance) giving you a sub 1 minute RTO. However, at scale, clicking on each VM to recover can become tedious, hard to manage and it will always require human interaction. This is where using PowerShell to interact with REST APIs is going to make your life easier by automating the entire process for anything from 1 to 10,000+ VMs. Use cases include: Read more of this post

Introduction to Rubrik REST APIs using PowerShell & Swagger

One thing I’ve always been passionate about is writing scripts that are easy to read and consume. By showing you how to directly interact with REST APIs this enables you to do anything, and not be limited to the PowerShell functions provided by the vendor.

When it comes to working with REST APIs and PowerShell this starts to pay dividends when you want to take all the knowledge you’ve learned from working with 1 platform then use the same skills to connect and leverage another.

My first example of porting skills between platforms follows my recent journey of switching from working for Zerto to Rubrik. In this post I will give you all the information needed to connect and leverage Rubrik REST APIs using PowerShell.

Read more of this post

Automated bulk IP address reconfiguration with Zerto Virtual Replication

If you tried to use this example before 04/25/17 there was a typo in the export script which left 2 key fields blank subsequently causing an error on import. I’ve now fixed the issue so now is as good a time as any to give this cool script a run in your Zerto environment for bulk IP configuration.

Logging Zerto Sync States Using REST APIs & PowerShell

A few days ago a Zerto prospect reached out to me on LinkedIn with an interesting script request and there is nothing like a good challenge to get me motivated to pull out PowerShell ISE! With over 1000 VMs to protect their key requirement was to log the start and end time of initial syncs. While the ZVR GUI shows when a VPG was created, it doesn’t show when the initial sync finishes:

CreateVPGEvent
This is certainly an annoying omission and the lack of specific data points isn’t limited to just Zerto; how many other solutions do you use in your environment where you want to know/see something that just isn’t there for seemingly no logical reason? Of course, you could contact your vendor account manager, raise a feature request, wait 3-6 months and cross your fingers that it was even considered let alone in the product. Or you can use the REST APIs to get the data yourself, today, in minutes!

Read more of this post

Connecting your home lab to Azure & AWS using a reverse SSL VPN

One big challenge that I came across when starting to use Microsoft Azure & AWS is how do I connect my home lab to a VM/instance running in the cloud?

I have multiple VMs in my lab that need to communicate with the cloud VM, yet my home router doesn’t allow me to create a VPN bridge. Neither does it allow me to do any port forwarding. If I was using an application that supports direct connectivity to Azure or AWS this isn’t a problem. However, in my case, I have Zerto Virtual Replication 5.0 which requires pre-existing connectivity to be established. So how did I workaround this issue? Watch the video to find out or keep on reading!

Read more of this post

Scripting a Zerto Recovery Plan v2

One of the most popular blog posts in the archive has been scripting recovery plans in Zerto. This is most likely because one of the most frequent requests I hear is the ability to control the boot ordering of Virtual Protection Groups (VPGs), not just the VMs within a VPG. This makes total sense when you have multiple tiers of applications and you want to recover them in order of priority or based on inter-dependencies.

In version 5.0 U2, Zerto included the ability to reverse the protection using the REST API. This meant I could finally deliver a script that automates failover and failback operations in a orchestrated fashion! In a first for virtuallysober.com I decided to give an overview of the script using a video:

Read more of this post

Top 10 PowerShell Tips & Tricks

In writing countless scripts over the past few years, I have learned many lessons on how to write scripts that are easier to read, more robust and perform ever more complicated tasks.

I recently had the pleasure of sharing these lessons with around 250 people on a Spiceworks webinar in the form of my top 10 PowerShell tips & tricks. I especially enjoyed the Q&A and live demo of my upcoming ZVR Recovery Plan v2 (coming very soon I promise). You can still watch the webinar recording by going to the link below and completing the form: Read more of this post