PowerCLI: Determine Deployment Times

Surprisingly it can be difficult to track exactly how long a VM has taken to deploy. So, I dug into the events part of powercli and came up with a way to calculate deployment times.

Basically the script is looking for the VMDeingDeployedEvent start time and then the VMDeployedEvent start time. We then take the difference of the 2 and print that out. It also matches up these 2 events based on a “chainid” that makes sure they match up.

If you have a large environment you might have to do many events to go back even a week. In my current environment that is of decent size about 500,000 events went back about a month.

The output is Name, Date, Minutes, Seconds for deploy and shows the oldest to newest, but you can sort it however you like.

Here is the script:

<#
.SYNOPSIS
   <A brief description of the script>
.DESCRIPTION
   <A detailed description of the script>
.PARAMETER <paramName>
   <Description of script parameter>
.EXAMPLE
   <An example of using the script>
#>

$samples = Read-Host "Enter Number of Samples to go back"

$events = Get-VIEvent -maxsamples $samples | where {$_.Gettype().Name -eq "VmBeingDeployedEvent" -or $_.gettype().name -eq "VmDeployedEvent"}
$VMDeployReport = @()
$events | where {$_.Gettype().Name -eq "VmBeingDeployedEvent"} | % {
        $row = "" | Select Name, Date, Minutes, Seconds
        $chainidkey = $_.chainid
        $VmName = ($_.FullFormattedMessage).split('')[1]
        $deployed = $events | where {$_.gettype().name -eq "VmDeployedEvent" -and $_.Chainid -eq $chainidkey}
        $StartTime = $_.createdtime
        #$date = $deployed.CreatedTime.ToString().split('')[0]
        $endtime = $deployed.createdtime
        $time = New-TimeSpan -start $starttime -end $endtime
        $row.Name = $VmName
        $row.date = $EndTime
        $row.Minutes = $time.Minutes
        $row.Seconds = $time.Seconds
        $VMDeployReport += $row
        }
        $VMDeployReport 
Advertisements

Interview with VMware’s Founder

I thought this was a very good interview so I figured I’d share!

Interview with Vmware Founder

PowerCLI: Host and VM location script across many Vcenters

If a company has a very large environment with many vcenters it sometimes can be difficult to track down where a host my be located.  Then let’s say you need to know what VM’s and what hosts are running on top of it? For this script you do need a list of hosts that you want to find.  If you want to just find out all the information you could modify the script to make the hostlist to just be get-vmhost instead of from a file.

I wrote a small script that once connected to all your vcenters, you can pass a csv with a list of hostnames and it will pull the VM’s, their host, and which VC it is in back out into a CSV.  In the script we are using the VIProperty cmdlet which lets you make your own property for objects in vmware.

The CSV will need to have the header “hostname” and then the FQDN of the hosts below it.

#Ready host file name in
$hostlist = Read-Host "Enter server list name"
$hostlist = Import-Csv $hostlist

# Create Vcenter Location Property
New-VIProperty -Name vCenterServer -ObjectType VMHost -Value {$Args[0].Uid.Split(“:”)[0].Split(“@”)[1]} -Force | Out-Null

#Loop through the hostlist and create spreadsheet.  Write for any hosts that aren't found.
$hostlist | %{
    Write-Host "Starting" $_.hostname
    if (Get-VMHost $_.hostname -ErrorAction SilentlyContinue ) { 
    $vmhost = get-vmhost $_.hostname
    $vmhost| get-vm | select Name,VMHost,@{Name="Vcenter";Expression={($vmhost | select vcenterserver).vcenterserver}}
    }
    else 
    {
        Write-host "Failed to find" $_.hostname 
    }
} | Export-Csv -NoTypeInformation vm_list.csv

VMware Product Walkthrough Videos

I recently stumbled across an excellent page from VMware that I had never seen before.  I figure others would enjoy this page as much as I do.  On the page it has a collection of videos provided for many of their offerings to get you up to speed!  It’s a nice little nugget of information that I hope others will enjoy.

https://featurewalkthrough.vmware.com/

vmwarefeatures

Blogging this year….A challenge

I haven’t had too many updates this year, but I am not quitting on the blog.  There has just been a large amount of work internally where I work.

There are many initiatives I am leading up which should provide some excellent blogging material once I have more information.  We are currently testing out automation suites and hyperconverged infrastructures.

I hope to begin blogging on my experiences with these as soon as I can find more time.

Vsphere 6 Now Available for Download

Vsphere 6 is now officially released.  So, get to downloading and testing!

vsphere6

Back to Basics: Troubleshooting VM Network Connectivity

Sometimes those of us that have been doing virtualization for a while forget that others that haven’t been doing it don’t always know where to look at.  So, in this post I am going to go over the things to check when you are having issues connecting to a VM.

1.  First step to check is whether the OS has the proper network information, ip, gateway, subnet to get out.

network4

2.  If step 1 is good, you then want to check under the settings of the VM and make sure that the virtual nic is connected.

network1

3.  Next, check to make sure you are connected to the proper virtual network.  If you have a standard switch and a VDS, make sure you select the right one.

network2  4.  Make sure that your portgroup is configured correctly and your switch has physical uplinks connected.  Check that the VLAN ID is correct.network35.  Final thing to check is whether the VLAN is authorized and ports enabled for the physical port that the phsycial NIC is connected to.

6.  Beyond this you would need to check the physical switch configurations to make sure it is configured properly for the traffic.