Skip to main content

User Guide for the Import OVA files

Prerequisites​

The following files and folders should have been sent to you along with this guide:

ItemDescription
Import-VMs-from-OVA.ps1The script itself
ovftool folderAuxiliary tool required by the script
.ova filesVirtual machine files to be imported, such as Mux.ova and Access.ova
This guideThis file

You also need PowerShell installed on your system. On Windows, PowerShell is available by default.


Step 1: Preparing Files on the System​

  1. Copy the ovftool folder to a path on your system; for example:
C:\Tools\ovftool
  1. Place the .ova files in a specific folder; for example:
E:\Exports
  1. Save the Import-VMs-from-OVA.ps1 file on the system.

Adding ovftool to PATH​

  1. Press the Windows key, search for Environment Variables, and open it.

  2. Click Environment Variables.

  3. Under System variables, select the Path variable and click Edit.

  4. Add the path to the folder containing ovftool.exe; for example:

C:\Tools\ovftool
  1. Close all windows with OK, and open a new PowerShell window.

To verify this step, run the following command in PowerShell:

Get-Command ovftool

If the configuration is correct, the path to ovftool.exe should be displayed.

Note: If the above command returns an error, the step to add ovftool to PATH was not completed correctly.


Step 2: Editing the Script​

Open the Import-VMs-from-OVA.ps1 file with Notepad or PowerShell ISE.

At the beginning of the file, there is a section named CONFIGURATION. Change only the following values according to your environment:

$EsxiHost = "172.16.41.3" # Destination ESXi server IP
$Datastore = "DataStore" # Datastore name on the destination server (without [] and case-sensitive)
$SourceDir = "E:\Exports" # Folder where the .ova files are located
$VMNames = @("Mux", "Access") # VM names; must exactly match the .ova file names (without extension)
$DiskMode = "thin" # Disk mode

Important Notes When Editing​

  • Replace the $EsxiHost value with the IP of your ESXi server.

  • The $Datastore value must be exactly the same as the datastore name on the destination server, and it is case-sensitive.

  • If your .ova file names differ from Mux.ova and Access.ova, change the $VMNames list to match the file names. For example, if your files are Web.ova and DB.ova:

    $VMNames = @("Web", "DB")
  • In $VMNames, the file names must be written without the .ova extension.

After applying the changes, save the file.


Step 3: Running the Script​

  1. Open PowerShell with the Run as Administrator option.

  2. Navigate to the folder where the script is located:

cd C:\path\to\script\folder
  1. If running the script results in an Execution Policy error, run the following command once:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
  1. Run the script:
.\Import-VMs-from-OVA.ps1

Step 4: Entering Credentials at Runtime​

When run, the script asks you for the following information:

PromptDescription
Enter ESXi usernameESXi server username; usually root
Enter ESXi passwordPassword for that user; it is not displayed while typing

After receiving the login information, the script automatically imports all virtual machines defined in $VMNames, in order.

The progress of the operation is also displayed in the same PowerShell window.


Step 5: Checking the Result​

At the end of the run, the script displays a summary of the operation result:

  • If a SUCCESS message appears in green, that virtual machine was imported successfully.

  • If a FAILED message appears along with an error code, that virtual machine failed to import.

At the end of the output, a list of successful and failed virtual machines is also displayed.


Step 6: After Import — Important​

Virtual machines are imported in a Powered OFF state, and the script intentionally does not power them on.

Before powering on each virtual machine, perform the following steps:

  1. Log in to the ESXi server management interface, such as vSphere Client or Host Client.

  2. Right-click the imported virtual machine and select Edit Settings.

  3. Check the Network Adapter section:

    • The virtual machine may be connected to a portgroup that does not exist.
    • The network adapter may be completely Disconnected.
  4. Correct the NIC settings and click OK.

  5. After ensuring the settings are correct, power on the virtual machine.


Troubleshooting Common Errors​

ErrorCause and Solution
ERROR: ovftool not found in PATHThe step to add ovftool to PATH was not completed, or PowerShell was not reopened after changing PATH.
ERROR: You still need to set EsxiHost...The EsxiHost or $Datastore values in the CONFIGURATION section have not been edited.
ERROR: Cannot find ... \Mux.ovaThe SourceDir path is wrong, or the file name does not match the VMNames value.
FAILED: ... (exit code ...)Usually occurs due to an incorrect IP, username, password, or datastore name. Check the CONFIGURATION section values and credentials.
Execution Policy error when runningRun Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass, then run the script again.

Summary​

Before running the script, check the following:

  • ovftool has been added to PATH.
  • The $SourceDir path is correct.
  • The $EsxiHost value is correct.
  • The $Datastore name exactly matches the ESXi datastore.
  • The $VMNames values match the .ova file names.
  • The ESXi login credentials are correct.
  • After import, the Network Adapter settings of the virtual machines are checked.