Virtually Sober

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

Monthly Archives: June 2017

REST API changes in Zerto Virtual Replication 5.0 U3

Since my first post back in 2014, many of the example scripts that I’ve shared integrate with Zerto using their bolt-on REST APIs. After 4 years of stability, in 5.0 U3, Zerto changed the requirements of the authorization header to require the content type in addition to the session token as a “security” feature.

Unfortunately, this means that any Zerto script you have downloaded from my blog, customized, or written, needs to be edited to continue working after the upgrade. Without any modification, your REST API calls to Zerto won’t even give you an error, they will just return null. Pretty annoying huh? I’ll be honest in that I was completely livid when I found out. To me, this looks like a pointless change to fix a problem that didn’t exist while creating a heap more by how it is was implemented and communicated.

On top of this, the Zerto API documentation leaves a lot to be desired as it hasn’t even been updated (as of 06/25/17) to reflect the new requirements! But that’s why I’m here to help. So how do you go about fixing your Zerto scripts?

Read more of this post

Automatically detecting Ransomware infections with PowerShell

Back in July 2016, I posted a script which used PowerShell to send an email alert upon detecting a Ransomware infection by continuously comparing a purposefully vulnerable word doc for changes, deletion etc. The script also integrated into Zerto to insert a checkpoint, but what if you don’t have Zerto and you just want to get the email alerts? I’m presenting at Foxwoods Casino with a Rubrik partner this afternoon on Ransomware (the irony of the venue and subject not lost on me) and so I wanted to post a non-vendor integrated example as a free giveaway for everyone attending the presentation and reading the blog. This post will give you just that.

Read more of this post

Bandwidth throttling your home lab and Rubrik replication/archiving

Having your own home lab is one of the best tools you can have to progress your knowledge and career in IT. But, having lots of VMs and hardware can equal a decent load on your home internet connection. This gets even worse when you start using replication and archiving technologies. So how can you stop your home lab from saturating your internet connection, interrupting the family movie night (yes this happened to me), and the plethora of streaming services used in a modern household?

Read more of this post

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