When doing an Instant VM recovery or a Linux FLR recovery using Veeam Backup & Replication it will create a NFS share within a VMware infrastructure which allows it to power on VM’s directly from a backup file. However when the restore is done the NFS share remains in the infrastructure. This is done to speed up future recoveries.

I received the question if there was a way to auto-unmount the datastore once a restore was done. This is currently not possible but the following script will remove any NFS datastore in the infrastructure called “VeeamBackup_” on all hypervisors.

# Script to unmount Veeam vPower NFS datastore
 
# Fill in the information below
# vCenter server address (FQDN or IP)
$vcenter = "IP-HOSTNAME"
# vCenter Username
$user = "SOMEADMIN"
# Password
$pass = "SOMEPASS"

# DO NOT TOUCH BELOW!!
 
# Connect to vCenter
Connect-VIServer -Server $vcenter -Username $user -Password $pass | Out-Null

$hosts = Get-VMHost
foreach ($VMHost in $hosts) {
    $veeamshare = Get-Datastore | where {$_.type -eq "NFS" -and $_.name -Match "VeeamBackup_*"}
    Remove-Datastore -VMHost $VMHost -Datastore $veeamshare -confirm:$false
}
 
# Disconnect from vCenter
Disconnect-VIServer -Server $vcenter -Confirm:$false | Out-Null

You can automate this task by running the script as a scheduled task.

Enjoy!

VMware Labs released a new Fling called vCenter 5.1 Pre-Install Check Script. The download is available as zip package and the total size is about 1MB.

5.1 Pre Install Check Script

Quote taken from the Fling page:

This is a PowerShell script written to help customers validate their environment and assess if it is ready for a 5.1.x upgrade. The script checks against known misconfiguration and issues raised with VMware Support.

This script checks the Windows Server and Active Directory configuration and provides an on screen report of known issues or configuration issues, the script also provides a text report which can help with further trouble shooting.

Sounds great doesn’t it? The script automatically performs several checks and provides you with clear information if you are “ok to go” or not :-). I can only say thanks to everyone who helped writing this script (probably Alan Renouf all alone but maybe PowerCLI man helped as well?) as I will find it useful and I hope that whenever a new VMware release comes out this script will also get some love :-).

The checks!

  • Operating System Checks
  • Active Directory Domain Checks
  • Active Directory Forest Checks
  • Time Synchronization Checks
  • Domain Name System (DNS) Resolution Checks
  • Port Checks
  • Domain Controller Checks
  • vCenter Server Authentication Checks

Requirements

  • Windows 2003/ Windows 2008/2008 R2 on 64bit in a domain environment
  • .Net Framework 3.5.0 or above
  • PowerShell 2.0 or above
  • PowerShell must be able to run scripts (Execution Policy must be assigned correctly)
  • PowerCLI 5.1 is required for an upgrade scenario
  • PowerShell must be launched as Administrator
  • Run in 64 Bit PowerShell (Do not run in PowerShell (x86))

Installation

The installation is very easy. A run down list can be found at the instruction tab at the fling page.

If you need more information make sure to check out the video released by Alan Renouf.

Session abstract

In this session Technical Marketing automation experts William Lam and Alan Renouf will take you through What’s New in ESXCLI and PowerCLI for the vSphere 5.1 release. In this session Alan and William will take you through the exciting features available to use when automating VMware products, both beginners and experts will learn how to use new features to make your life easier and more productive.

The session

The session was split into 2 parts, first William talked about (some of) the new ESXCLI functions and improvements with demo’s. First of all ESXCLI 5.1 still works with vSphere 4.0, 4.1 and 5.0.

There are 82 new commands in the new release:

  • 7 hardware
  • 2 sched
  • 47 network
  • 15 storage
  • 11 system

One of the best things in my opinion is SNMP support which got improved. Furthermore William showed some demo’s about several commands like:

  • Host maintenance operations
  • Network coredump check improvement
  • SR-IOV configurations
  • Network statistics and monitoring
  • SSD monitoring

There are quite some new operations and showing them all would probably take a while :-).

Next up was Alan who talked about the PowerCLI. He started with a small overview on what PowerCLI is. PowerCLI is a free product containing over 300 cmdlets (PowerShell Commands) to use. They can manage every aspect of your VMware environment and it is integrated into PowerShell.

PowerCLI 5.1 is backwards compatible all the way down till ESX 4.0 and Virtual Center 4.0!

PowerCLI has several snap-in’s:

  • Core: managing vSphere
  • Image Builder: working with Image Profiles
  • Auto Deploy: deploy ESXi using PXE
  • License: work with vSphere Licensing
  • Cloud: vCloud Director Providers
  • Tenant (NEW!): vCloud Director Tenants

We then received some information on each part with the “what’s new” list and finally information regarding the Tenant Snap-in.

There are 361 cmdlets in PowerCLI for Admins and 56 cmdlets for Tenants!

In the end we saw a new “cool demo” which will be released into a fling. This basicly deployed a full vCloud in a few minutes. I can’t wait till they release this and I will sure be posting about it when it gets released!

When you do an “Automatic Tools Upgrade” on a virtual machine the VMware tools iso will be mounted into the VM. Unfortunately it sometimes happens that after the upgrade the iso stays attached and this will result in a warning while doing a manual VMotion.

When you inspect the VM (edit settings) you will see the ISO being mounted.

You can change this to Client Device and the ISO will be unmounted and the warning won’t be shown anymore. Obviously this isn’t something you want to do manually on all your VMs and therefor the following PowerCLI one-liner will help you.

Get-VM | Get-CDDrive | Where { $_.IsoPath } | Set-CDDrive -NoMedia -Confirm:$false

Veeam logo
Veeam Backup & Replication comes with a few built-in PowerShell cmdlets. Sadly I couldn’t find a cmdlet which allows me to monitor running Veeam FLR sessions.

Keep in mind that this post only works when you run a FLR which is a non-Windows virtual machine!!

When you perform a restore, Veeam Backup & Replication will start an extra virtual machine which runs with the name VeeamFLR-SERVERNAME-randomhash. The script below will see if a restore is running for a defined amount of hours and then update you with an e-mail.

# Script to determine running Veeam FLR sessions (type: Other OS)
# E-mails a small overview with open sessions with XX hours uptime

# Fill in below
# Set the vCenter Server address
$vcenter = "hostname/ip"
# Set the SMTP Server address
$smtp = "mail.company.com"
# Set the Email address to receive from
$emailfrom = "veeamflr@company.com"
# Set the Email address to send the email to
$emailto = "you@company.com"
# Set the Email subject
$emailsubject = "Veeam FLR Session Running!"
# Uptime a session can have before sending an e-mail (defined in hours)
$hours = "1"

# Don't change below!
New-VIProperty -ObjectType VirtualMachine -Name BootTime
-ValueFromExtensionProperty Summary.Runtime.BootTime -Force | Out-Null

# E-mail function
function Send-Mail($to, $from, $subject, $smtpserver, $body) {
	$mailer = new-object Net.Mail.SMTPclient($smtpserver)
	$msg = new-object Net.Mail.MailMessage($from, $to, $subject, $body)
	$msg.IsBodyHTML = $false
	$mailer.send($msg)
}

# Connect to vCenter
Connect-VIServer -Server $vcenter | Out-Null

# Store sessions in a variabele
$runningsessions = @()

# Loop through VM's starting with "VeeamFLR"
foreach ($vm in Get-VM | where {$_.Name.ToLower().Contains("veeamflr")} |
Select Name, BootTime) {
	if ($vm.BootTime -ne $null) {
		$boottime = [DateTime]::Parse($vm.BootTime.ToLocalTime().DateTime)
		$uptime = [DateTime]::Now.Subtract($boottime)
		$upthours = [int]::Parse($uptime.Hours)
		if ($upthours -gt $hours) {
			$runningsessions += $vm.Name + " `r`n"
		}
	}
}

# Only send an e-mail if there are running sessions
if ($runningsessions -ne $null) {
	$body = "Veeam FLR report:`r`n"
	$body += "===============`r`n`r`n"
	$body += $runningsessions | Sort-Object

	# Send the e-mail
	Send-Mail -to $emailto -from $emailfrom -subject $emailsubject
-smtpserver $smtp -body $body
}

# Disconnect from vCenter
Disconnect-VIServer -Server $vcenter -Confirm:$false | Out-Null

You can automate this task by running the script as a scheduled task.

Enjoy!