← script library

Hyper-V Virtual Machine Export Script

Hyper-VJanuary 10, 2025

In this post, we will present a PowerShell script that allows you to export Hyper-V virtual machines easily. This script is particularly useful for backing up VMs or transferring them between servers. Being able to export your VMs ensures that your data is safe and can be restored or migrated as needed.

powershell
$vmName = 'YourVMName'

$exportPath = 'C:\VMExports\' + $vmName + '_' + (Get-Date -Format 'yyyyMMdd_HHmmss')

Export-VM -Name $vmName -Path $exportPath -Force

Write-Host "Export of VM '$vmName' completed successfully to '$exportPath'."

Run it across your fleet

This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.

Ready when you are.

Try ServerEngine free for 7 days.