«

»

Aug 02 2013

Use PowerCLI to compare virtual machine configured and installed guest operating system

When i presented the result from a vSphere health check the other day my costumer was quite surprised that a few of his virtual machines had an installed guest operating system that didn’t match the guest operation system configured in vSphere.

Several other blogs covers the importance of having a configured guest operating system in vSphere that matches the guest operating system running in the virtual machine so i will not cover that in detail in my blog post. You will e.g. get the correct VMware Tools version based on your configured guest operating system.

My customer asked me to create an process that verifies if any virtual machine has a configured guest operating system that does not match the installed guest operating system. If the process found any mismatch he wants the process to:

  • Log the virtual machine names to a file.
  • Send the file in an e-mail to a specific e-mail address.

Below you’ll find the PowerCLI script i implemented in my customers environment that is running vSphere 5.1 U1.
Change the following parameters in the below script to match your environment:

  • $vcenter = “vc01.vcdx56.local”
  • $vcenteruser = “vcdx56\magnus”
  • $vcenterpw = “not secret”
  • $sendTo = “magnus@vcdx56.local”
  • $sendFrom = “vc-demo01@vcdx56.local”
  • $smtpserver = “smtp.vcdx56.local”

This is the e-mail report, with open attachment, you’ll receive when the script is finished.
Screen Shot 2013-08-02 at 20.05.18 Screen Shot 2013-08-02 at 20.05.08

1 comment

  1. Justin

    Very nice! Worked well first time. Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">