Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VM Import/Export for vCenter & ESXi

PowerShell Platform PowerCLI License Version

An interactive PowerShell tool to export and import virtual machines against a VMware vCenter (including Distributed Switch environments) or a standalone ESXi host. Built on VCF.PowerCLI.

Why

Exporting a VM to OVF/OVA and importing it again is straightforward against a single ESXi host, but importing into a vCenter that uses a vSphere Distributed Switch (VDS) often fails — the network has to be mapped before the VM is created. This tool solves that by mapping every OVF network to a target port group via Get-OvfConfiguration prior to Import-VApp.

Features

  • Single menu-driven script for both export and import
  • Automatic detection of the connection type (vCenter vs. standalone ESXi)
  • Interactive network mapping to Distributed or Standard port groups
  • OVF or OVA export (with a short explanation of the difference)
  • Per-VM settings remembered in config.json and offered for reuse next run
  • Secure credentials: prompt with optional encrypted storage (Windows DPAPI)
  • Graceful guest shutdown before export, with power-state restore afterwards
  • Module preflight: checks/installs VCF.PowerCLI (CurrentUser scope; elevation only as a fallback)
  • Console and file logging

Requirements

  • Windows PowerShell 5.1 or PowerShell 7+
  • VCF.PowerCLI (installed automatically on first run if missing)
  • Network access to your vCenter/ESXi endpoint

Usage

.\VM-ImportExport.ps1

Follow the menu:

Key Action
1 Export VM(s)
2 Import VM(s)
C Switch connection
Q Quit

On first run you are prompted for server, username and password. Every prompted value is stored in config.json next to the script and offered as a default the next time (press Enter to keep it). When the same VM(s) are selected again, the tool summarizes the saved settings and offers to reuse them.

OVF vs. OVA

  • OVF — a folder of separate files (.ovf descriptor + .vmdk disk(s) + .mf manifest). Faster to write, easy to inspect/edit individual files.
  • OVA — a single packaged archive (.ova), a tar bundle of the same OVF set. One portable file, easier to copy/share, but must be unpacked to edit.

The importer auto-detects both OVF folders and OVA files in the source path.

Configuration & security

  • config.json (git-ignored) holds non-secret settings and per-VM profiles.
  • cred_<server>_<user>.xml (git-ignored) holds optional DPAPI-encrypted credentials, decryptable only by the same user on the same machine. Passwords are never written to config.json.
  • Logs are written to logs/ (git-ignored).

Notes

  • A VM must be powered off to be exported; the script handles this via a graceful guest shutdown (falling back to a hard power-off) and can restore the original power state afterwards.
  • For vCenter targets the importer prefers a cluster (letting DRS place the VM); otherwise it targets an individual host.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages