PowerShell script to tell you if you need to update your Integration Services

PowerShell script to tell you if you need to update your Integration Services

Rate This
  • Comments 6

A while ago I did a blog post that showed you how easy it was to check what version of the Integration Services were installed inside your virtual machines.  However, a number of people came back to me and said: “Ben, I do not really care about the version number of the integration services – what I want to know is whether I need to update the integration services or not”.

Hmm…

That is a much trickier problem to solve.  In fact, in Windows Server 2008 and Windows Server 2008 R2 it is not really possible to write a good script that will do this.  Luckily, it is possible to write a script for this in Windows 8 / Windows Server 2012.  Unfortunately, it is not the simplest script around.

There are a couple of reasons for this:

  1. You can’t do this with the Hyper-V PowerShell cmdlets, you need to go straight to WMI
  2. This information is only available through GetSummaryInformation – which is a rather strange interface

With that in mind – here is the script that will get you the information you need:

# GetSummaryInformation documented here: http://msdn.microsoft.com/en-us/library/hh850062(v=vs.85).aspx
# MSVM_SummaryInformation documented here: http://msdn.microsoft.com/en-us/library/hh850217(v=vs.85).aspx
 
# Get the Management Service from the v2 namespace
$VMMS = gwmi -namespace root\virtualization\v2 Msvm_VirtualSystemManagementService
 
# 1 == VM friendly name. 123 == Integration State
$RequestedSummaryInformationArray = 1,123
$vmSummaryInformationArray = $VMMS.GetSummaryInformation($null, $RequestedSummaryInformationArray).SummaryInformation
 
# Create an empty array to store the results in
$outputArray = @()
 
# Go over the results of the GetSummaryInformation Call
foreach ($vmSummaryInformation in [array] $vmSummaryInformationArray)
   {  
 
   # Turn result codes into readable English
   switch ($vmSummaryInformation.IntegrationServicesVersionState)
      {
       1       {$vmIntegrationServicesVersionState = "Up-to-date"}
       2       {$vmIntegrationServicesVersionState = "Version Mismatch"}
       default {$vmIntegrationServicesVersionState = "Unknown"}
      }
 
   # Use Hyper-V PowerShell cmdlets to quickly get the integration version number
   $vmIntegrationServicesVersion = (get-vm $vmSummaryInformation.ElementName).IntegrationServicesVersion
   # Display "Unknown" if we got a null result
   if ($vmIntegrationServicesVersion -eq $null) {$vmIntegrationServicesVersion = "Unknown"}
 
   # Put the VM Name, Integration Service Version and State in a PSObject - so we can display a nice table at the end
   $output = new-object psobject
   $output | add-member noteproperty "VM Name" $vmSummaryInformation.ElementName
   $output | add-member noteproperty "Integration Services Version" $vmIntegrationServicesVersion
   $output | add-member noteproperty "Integration Services State" $vmIntegrationServicesVersionState
 
   # Add the PSObject to the output Array
   $outputArray += $output
 
   }
 
# Display information in nicely formatted table
write-output $outputArray | sort "VM Name"

If I run this script on one of my Hyper-V servers – I get this:

ICVersion

Looks like I need to do a lot of integration service updates.  Bummer.

But getting back to the script – what is GetSummaryInformation and why is it so tricky to use?  GetSummaryInformation is a WMI method that we implemented to allow people to get a lot of random information about virtual machines in a quick and efficient method.  The way it works is that you call it and pass in an array of numbers – this array indicates the information that you want to get about the virtual machines.  You can read all of the possible options here: http://msdn.microsoft.com/en-us/library/hh850217(v=vs.85).aspx

One final note – in order to get the Integration Services state – you need to use the WMI v2 namespace.

Cheers,
Ben

Attachment: CheckICs.zip
Leave a Comment
  • Please add 5 and 3 and type the answer here:
  • Post
  • Hi there,

    When I run this script, I get the following error:

    You cannot call a method on a null-valued expression.

    At line:1 char:1

    + $vmSummaryInformationArray = $VMMS.GetSummaryInformation($null, $RequestedSummar ...

    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

       + CategoryInfo          : InvalidOperation: (:) [], RuntimeException

       + FullyQualifiedErrorId : InvokeMethodOnNull

    I know that I did something wrong here, but not sure what!

    Ta

  • EF -

    Most likely you will need to run this from an elevated PowerShell window.

    Cheers,

    Ben

  • I manage to achieve this in WS08R2 by using the version of the "vmbus.sys" driver as a proxy for the version of the IC. I then wrote this to a registry key inside the VM.

    The (driven by SCOM) I ran a daily task to check the version of the IC of the Hyper-V host against the stored value in the registry of the VMs it was hosting. I'd post the scripts here if I could, but the length of the post is limited.

  • Hey I am a fan of your posts and I  just want to point you to my blog and a couple of powershell scripts I have created them from a hodge podge of sites (yes even yours) and just trial and error, not a programmer just old school administrator

    stephanco.blogspot.com/.../detailed-report-of-your-hyper-v-server.html    this creates a text file report of the vhost and vm’s

    stephanco.blogspot.com/.../new-vm-powershell-commandlet-to-easily.html  this is an easy way to create vm’s from powershell, best I have found and easy to understand

    I was hoping you could improve them or post them for others to use, my blog is not all that popular but I want to share.

  • Dear Ben,

    Is there a way to update the Integration Services for all VMs using a script instead of login to each VM and do it manually?

    This will be very handy in large HOST.

    Thanks,

  • Sadly it does show Linux host only as Unknown

Page 1 of 1 (6 items)