Add Virtual Machine Templates (.VMTX) to Inventory using PowerShell

Here is a script that will scan a datastore for VM templates (.VMTX) and add them to inventory. This is a modified version of the Add Virtual Machines (.VMX) to Inventory script.

You must have VMware PowerCLI installed in order to have the cmdlets required for PowerShell to run the script.

Add VMTX (Virtual Machine Templates) to Inventory from a Datastore:

#####################################################################
# Load VMware Plugins and vCenter Connect #
#####################################################################

Add-PSSnapin vmware.vimautomation.core

connect-viserver -server ENTER VCENTER FQDN HERE
#####################################################################
# Add .VMTX (VM Templates) to Inventory from Datastore #
#####################################################################

# Variables: Update these to the match the environment
$Cluster = "ENTER CLUSTER NAME HERE"
$Datastore = "ENTER DATASTORE NAME HERE"
$VMFolder = "ENTER FOLDER NAME HERE"
$ESXHost = Get-Cluster $Cluster | Get-VMHost | select -First 1

foreach($Datastore in get-datastore $Datastore)
{
# Collect .vmtx paths of registered VMs on the datastore
$registered = @{}
Get-Template -Datastore $Datastore | ForEach-Object -Process {
$registered.Add($_.Name+'.vmtx',$true)
}

# Set up Search for .VMTX Files in Datastore(s)
$null = New-PSDrive -Name TgtDS -Location $Datastore -PSProvider VimDatastore -Root '\'
$unregistered = @(Get-ChildItem -Path TgtDS: -Recurse | `
Where-Object -FilterScript {
$_.FolderPath -notmatch '.snapshot' -and $_.Name -like '*.vmtx' -and !$registered.ContainsKey($_.Name)
}
)
Remove-PSDrive -Name TgtDS

#Register all .vmtx Files as VMs on the datastore
foreach($vmtxFile in $unregistered)
{
New-Template -Name $vmtxFile.Name -TemplateFilePath $vmtxFile.DatastoreFullPath -VMHost $ESXHost -Location $VMFolder -RunAsync
}
}

Let’s see it in action!

Read more…

Add Virtual Machines (.VMX) to Inventory using PowerShell

There are quite a few clicks to add a virtual machine from a datastore to inventory. If you were to consolidate an environment and had to add multiple virtual machines this would be quite a manual task. Easier solution? Script it! The below script makes scanning a datastore and registering all virtual machines with vCenter a breeze.

You must have VMware PowerCLI installed in order to have the cmdlets required for PowerShell to run the script.

Add VMX (Virtual Machines) to Inventory from a Datastore:

#####################################################################
# Load VMware Plugins and vCenter Connect #
#####################################################################

Add-PSSnapin vmware.vimautomation.core

connect-viserver -server ENTER VCENTER FQDN HERE
#####################################################################
# Add .VMX (Virtual Machines) to Inventory from Datastore #
#####################################################################

# Variables: Update these to the match the environment
$Cluster = "ENTER CLUSTER NAME HERE"
$Datastore = "ENTER DATASTORE NAME HERE"
$VMFolder = "ENTER FOLDER NAME HERE"
$ESXHost = Get-Cluster $Cluster | Get-VMHost | select -First 1

foreach($Datastore in $Datastore) {
# Searches for .VMX Files in datastore variable
$ds = Get-Datastore -Name $Datastore | %{Get-View $_.Id}
$SearchSpec = New-Object VMware.Vim.HostDatastoreBrowserSearchSpec
$SearchSpec.matchpattern = "*.vmx"
$dsBrowser = Get-View $ds.browser
$DatastorePath = "[" + $ds.Summary.Name + "]"

# Find all .VMX file paths in Datastore variable and filters out .snapshot
$SearchResult = $dsBrowser.SearchDatastoreSubFolders($DatastorePath, $SearchSpec) | where {$_.FolderPath -notmatch ".snapshot"} | %{$_.FolderPath + ($_.File | select Path).Path}

# Register all .VMX files with vCenter
foreach($VMXFile in $SearchResult) {
New-VM -VMFilePath $VMXFile -VMHost $ESXHost -Location $VMFolder -RunAsync
}
}

Let’s see it in action!

Read more…

Deployment of VMware vRealize Operations Manager

vRealize Operations Manager (vROM/vROPS) gives you visibility into the performance and health of your virtual infrastructure. The bad thing about virtualization is how easy it is to accumulate over-provisioned virtual machines. When your environment grows the numbers can really be staggering. With vROM you can find these VMs and really tweak your environment making it more lean and resource efficient. vROM also has the ability to ensure compliance with IT policies, regulatory requirements, and smart alerting. Basically vRealize Operations Manager will take your structure data like performance metrics and give you a unified interface of analytics. Here is my documented deployment of vRealize Operations Manager 6.0.1 in my lab environment.

vRealize Operations Manager Logo

Planning and Reading:

Read more…

Lost connectivity to the device backing the boot filesystem

One of our HP Gen 9 blades had the following configuration error: Lost connectivity to the device mpx.vmhba32:C0:T0:L0 backing the boot filesystem /vmfs/devices/disk/mpx.vmhba32:C0:T0:L0. As a result, host configuration changes will not be saved to persistent storage. The boot filesystem is on an internal 8 GB SD Card. I logged into iLo, went to Diagnostics and found the system no longer saw the SD Card as mounted: We evacuated the host and reseated the SD Card. It mounted without issue but to be safe we went ahead and installed a replacement SD Card. Issue reoccurred. This is caused by the version of iLo running on the server. EDIT (9/14/2015): There seems to be a issue with the iLO firmware version 2.20 causing this issue. The firmware should be updated to version 2.22. HP should be releasing version 2.30 in the next few weeks that hopefully be a full fix for this issue! Big thanks to Mike B. for reporting his findings from HP!!! EDIT (10/2/2015): The new HP Service Pack for Proliant (SPP) (dated version 2015.10.0) contains updated iLO firmware 2.30! We are rolling this through our environment over the next week. EDIT (12/4/2015): The 5+ blades we upgraded to iLo 2.30 haven’t had the issue repeat.  EDIT (12/10/2015): Multiple reports of the issue reoccurring on iLo 2.30 firmware have been received. Though 2.30 firmware seems to have helped the issue it …

Read more…

Deprecated VMFS volume(s) found on the host

One of my ESXi 6 hosts had the configuration issue message stating: “Deprecated VMFS volume(s) found on the host. please consider upgrading volume(s) to the latest version“. I only have two LUNs presented to my hosts and both are VMFS5: After some brief searching I found VMware KB article 2109735 which states the possible cause: This issue occurs because at the time of initial detection, the version of the filesystem is not known. Therefore, comparing it against the list of valid filesystems does not return a match. Looking through the hostd log I did find the entry mentioned in the KB article. It appears that after I renamed my StarWind LUN it did not report the filesystem to the host fast enough which caused the error to occur: /var/log/hostd.log The resolution was to restart the management agents on the host. I put the host in maintenance mode then restarted the management agents: services.sh restart After the management services restarted the error cleared: Leave comments below if you received this message and this KB article resolved your issue! KB2109735: http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2109735&src=vmw_so_vex_sbori_1079

Upgrading Windows based vCenter 5.x to 6

For this post I will go through upgrading my Windows based vCenter from 5.5 to vCenter 6. VMware has really made the installer process lean. I would even go out on a limb and say “easy”! vCenter 6 introduces the Platform Services Controller which changes the architecture of vCenter down to two components. The graphic below shows my environment before the upgrade and after:

Upgraded Embedded Architecture

My setup is very simple as I have all vCenter 5.5 components on a single Server 2012 virtual machine. I have ran through the upgrade multiple times and have yet to run into anything major. To find what your environment will look like check out the VMware vCenter Server 6.0 Deployment Guide.

Read more…

vCenter Server Appliance Upgrade from 5.x to 6.0

The upgrade process of vCenter Server Appliance (vCSA) version 5.x to 6.0 isn’t truly a upgrade but more of a migration. You are basically deploying a second vCSA that will migrate the hosts/inventory/IP address from the old to the new. You can only upgrade vCSA versions 5.1U3 and 5.5. The 6.0 vCSA is still based on SUSE Linux Enterprise 11 and now has the the same mins/max as the Windows installed version.

vCenter 6 Appliance vs Windows

Before You Start:

There is some prep work you need to perform before doing the migration:

  • Pick a host and ensure it has a standard switch with a vmnic uplink. Because Distributed Switches is a vCenter function it wants to perform the upgrade on a standard switch.
  • Rename your current vCenter VM in the inventory so the new VM can be created as the same name. Otherwise the vCSA folders on the LUNs will not match.
  • Have at least two available LUNs, one for your current vCSA and one for the new vCSA. Since you will want to deploy the new one with the same name they have to be on different LUNs
  • The installation media is a .ISO instead of a .OVA. You will need to burn it to a disc, extract it, or mount it.

Read more…

vCenter Server Appliance 6.0 – A Fresh Install

The VMware vCenter Server Appliance (vCSA) is a security hardened SUSE Enterprise 11 operating system baked with the vCenter server function. With vSphere 6.0 the appliance now has the same mins/max as the Windows installed version. This makes it very appealing to move over to the appliance! Before You Start: Pick a host and ensure it has a standard switch with a vmnic uplink. Because Distributed Switches is a vCenter function it wants to perform the upgrade on a standard switch. The installation media is a .ISO instead of a .OVA. You will need to burn it to a disc, extract it, or mount it. If you want to upgrade your environment instead of fresh deployment, check out my posts Upgrading Windows based vCenter 5.x to 6 and vCenter Server Appliance Upgrade from 5.x to 6.0 PluralSight: PluralSight has amazing video courses on VMware vSphere. If you haven’t checked out PluralSight it’s an amazing service! Highly recommended! What’s New in VMware vSphere 6 vSphere 6 Foundations: Install and Configure vCenter and ESXi vSphere 6 Foundations: Configure vSphere Storage Installation: The VCSA is no longer a .OVA but instead a .ISO image so burn/extract/mount it on your computer. First we need to install the VMware Client Integration 6.0 Plugin. In the vcsa folder there is the executable named VMware-ClientIntegrationPlugin-6.0.0.exe.  The installation is simple, once installed proceed to the next …

Read more…

Unable to kill DCUI – ESXi 5.1

One of our ESXi 5.1 hosts entered a disconnected state with reason unknown. When I logged into the console of the server and checked the network settings everything checked out. Then I went into the ESXi shell to see what the network interfaces looked like and here laid the problem… the management vmkernel interface was not enabled. esxcli network ip interface list If you need to see what IP address is assign to each vmk, run this command: esxcli network ip interface ipv4 get Okay, no big deal…. that is a easy fix! But when I tried to enable it I received a “Unable to kill DCUI” error. esxcli network ip interface set -e true -i vmk0 I could not find any information about this error anywhere. With this production ESXi host disconnected and roughly 40 virtual machines still running on this server I admitted defeat and opened a support case with VMware. The VMware Support Engineer referenced internal KB article 2052878 with the fix below: First we need to find the processor ID of the DCUI. ps | grep -i DCUI Note: The number to the right of the Unable to kill DCUI error is NOT the PID. Use the command above Now kill that PID, it will not return anything if successful. kill -9 PID This should now let you enable the vmk interface esxcli network ip interface set …

Read more…