Automation

 View Only
  • 1.  Import-VApp Host did not have any virtual network defined

    Posted May 30, 2013 07:26 PM

    I have used the OVF tool to export a couple VM's from my 5.1 environment. When trying to import these VM's back into the environment using PowerCLi I get the error that is in the subject line. My hosts all currently use a VDS and one thing I read was add a virtual switch to the host that I am trying to import too. I have not tried that yet but I am curious why that would be required since it was not required on the export. I am using the 5.1 PowerCLi and my code is below.

    ********* Edit**********

    Adding a regular vswitch to the host the script is now working. I have on physical adapter assigned to it, but it is not connected.

    $items = Get-ChildItem -Path $OVF_Location -recurse | where {$_.psIsContainer -eq $false}

    $format = ".ovf"

    $VC_Password = ConvertTo-SecureString $VC_Password -AsPlainText -Force

    $VCcred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Virtual_Center_Username, $VC_Password

    Connect-VIServer -Server $Virtual_Center_Ip -Credential $VCcred

    foreach ($item in $items)

    {

      $filename = $item.Name

      if ($filename.Contains($format) -eq $true)

      {

            $vmhost = Get-Cluster | Get-VMHost | ?{$_.ConnectionState -eq "Connected"} | Get-Random

      $myds = Get-datastore | Get-Random

      if (($myds.FreeSpaceMB) -gt ($myds.CapacityMB * .25))

        {

      $datastore = $myds

      }

      else

      {

      Write-Host "There is not enough free space to create a Virtual Machine"

      exit

      }

      $importPath = $item | select fullname

      Write-Host "Importing OVF from: " $importPath.FullName " please wait as this will take some time."

      $path = $importPath.FullName

      Import-VApp -Source $path -VMHost $vmhost -Datastore $datastore

      }

    }

    Disconnect-VIServer -Force -Confirm:$false



  • 2.  RE: Import-VApp Host did not have any virtual network defined

    Posted Jul 12, 2017 11:19 PM

    You need to ensure that the destination hosts have a Standard Switch on them. It should go right through with that.

    The VApp needs networking and cant find any... only looks at Standard Switches, not VDS'.


    ... saw your edit when I read over it again



  • 3.  RE: Import-VApp Host did not have any virtual network defined

    Posted Jul 13, 2017 04:42 AM

    That is correct, see  2.  Re: How To - Migrate VM across vCenters using PowerCLI - bypass network validation

    But you should be able to override this with the OvfConfiguration parameter on the Import-VApp cmdlet.

    See Example 7.