0

I want to export all my VirtualBox VMs for backup purpose using an automated script. The following command should do the export in my PS script:

cmd.exe -c "vboxmanage export Antergos -o D:\Temp\test.ova"

By running the vboxmanage command in PowerShell, It shows me the progress in 10% steps like this:

PS C:\Users\XYZ> vboxmanage export Antergos -o D:\Temp\test.ova
0%...10%...

But using the cmd call like above I don't get any output. It would be great to have some progress, since some VMs are quite big (~70GB). I tried different variations:

iex 'vboxmanage export "$($name)" -o "$targetFile"'
& "vboxmanage export ""$($name)"" -o ""$targetFile"""
Invoke-Command -ScriptBlock { cmd.exe /c "vboxmanage export ""$name"" -o ""$fullTargetFile""" 4>&1 } 4>&1
Invoke-Expression "vboxmanage export ""${name}"" -o ""${fullTargetFile}"" 2>&1"

None of them show me the progress, which seems wired to me since e.g. Invoke-Expression "vboxmanage --help" print the help, but no progress when using vboxmanage export live above.

Lion
  • 16,606
  • 23
  • 86
  • 148

1 Answers1

0

I did it the following way and the vboxmanager output is shown for all operations.

$vmanagerBackup = @("VBoxManage.exe")
$vmanagerBackup += "export"
$vmanagerBackup += $vmName
$vmanagerBackup += "--ovf10"
$vmanagerBackup += $backupFilename
$vmanagerBackup = $vmanagerBackup -join ' '
Invoke-Expression "$vmanagerBackup"
zwnk
  • 101
  • 3