«

»

Sep 17

PowerCLI 5.8 New Feature: Import-vApp using Get-OvfConfiguration (Part 2 of 2)

in Part 1 we discussed how to add a configuration to the OvfConfiguration object (See Post HERE). In this post we will quickly discuss how to leverage the new –OvfConfiguration parameter when deploying vApps.

Import-VApp

PowerCLI has a nice little cmdlet called ‘Import-VApp’. This cmdlet allows us to import OVF and OVA packages into vSphere. Let’s run the get-help command to see what the cmdlet requires.

get-help Import-VApp

Looking under the SYNTAX section we can get a feel for what we can do with this cmdlet.

Screenshot2014091514.03.36_thumb.png

We will use the following information to deploy Log Insight:

  • Source (location of the target vApp)
  • OvfConfiguration (our hashtable or ovfconfiguration object)
  • Name (name of our VM)
  • VMHost (where the VM will reside)
  • Datastore (which datastore we want to place Log Insight on)
  • DiskStorageFormat (I prefer to use thin)

Assuming from the previous post that we now have an OvfConfiguration object ready to deploy a vApp. Let’s take a quick look at the hash table we have:

Screenshot2014091513.57.35.png

Ok, our hashtable ($ovfconfig) looks good. Let’s now populate our VMhost and Datastore variables.

$myhost = get-cluster “Main-CL” | Get-VMHost | Where {$_.PowerState –eq “PoweredOn” –and $_.ConnectionState –eq “Connected”} | Get-Random

$datastore = $myhost | get-Datastore | Sort FreeSpaceGB –Descending | Select –first 1

We’ll Name our VM “OVFConfig-LogInsight” since I feel that is very fitting for this example.

We now have all of the information we need to deploy Log Insight. We can put all of this information together in the following command:

Import-VApp –Source $ovfpath –OvfConfiguration $ovfconfig –Name OVFConfig-LogInsight –VMHost $myhost –Datastore $datastore –DiskStorageFormat Thin

Screenshot2014091513.53.55.png

When we hit enter, we see that the vApp is importing. Now we just need to wait for it to finish importing the package into vSphere.

Screenshot2014091513.54.02.png

Once the package has imported we can then power it on using the following command:

get-vm OVFConfig-LogInsight | Start-VM

Screenshot2014091513.55.51_thumb.png

We have now successfully created the configuration of the hashtable or configuration object and deployed the vApp into our environment using PowerCLI without having to leverage external scripts or modules, Enjoy!

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="">

2 × five =