Cyber Security

Hyper-V: Backup VMs to a shared folder with Windows Server Backup and a Scheduled Task

Last week I had the task to backup Hyper-V VMs. No Replica, no Clustering, a simple backup with Windows Server Backup. The problem was that a repeating backup job had already been set up. Windows Server Backup allows only one job in the graphic user interface. So, the task was to create a scheduled weekly job with the command line.

I can’t stress it enough, get familiar with PowerShell. More and more extraordinary tasks can only be one in the command line. And believe me, you want to be an extraordinary guy ;-), because it’s pretty cool to make things possible where others give up and buy the next product.

Creating the Backup Job

You have to adjust the command below to your needs. Note the backup target, which is a shared folder on a NAS and the Hyper-V VMs. The quiet parameter is mandatory, because the backup job will ask if you really want to do this. What is your scheduled job in your absence supposed to answer?  😉

wbadmin start backup -backuptarget:\\\hyper-backup -hyperv:"Server01,Server02" -allowDeleteOldBackups -quiet

This backups Server01 and Server02 to\hyper-backup.

Now open Notepad copy the command in a file and save this file (*.bat).


For the following make sure Windows Server Backup is installed.

Get-WindowsFeature Windows-Server-Backup


If not, hit the keys and run

Install-WindowsFeature Windows-Server-Backup -IncludeManagementTools


Creating the Scheduled Job

We are able to create a backup job either in the graphical user interface or in PowerShell. Well I think, it’s quite easier to do it in PowerShell, so I’ll show you the PowerShell code. My batch file is saved in C:\Temp\backupVM.bat. The code below creates a scheduled job that will run every Saturday at 11:00 am and is executed as sid-500\administrator. So pay attention to these values. I recommend using PowerShell ISE.

$Action=New-ScheduledTaskAction -Execute 'C:\Temp\backupVM.bat'
$Trigger=New-ScheduledTaskTrigger -Weekly -DaysOfWeek Saturday -At 11am
$Principal=New-ScheduledTaskPrincipal -UserId 'sid-500\administrator' -LogonType S4U
$Task=New-ScheduledTask -Action $Action -Trigger $Trigger -Settings $Set -Principal $Principal
Register-ScheduledTask -TaskName "Backup VM" -InputObject $Task -Force


Fine that’s it.

Windows 10 (Side Note)

I was really surprised about the presence of wbadmin on Windows 10. Thanks to Tom who noticed and commented that the -hyperv parameter is not available on Windows 10.

See you next time with PowerShell again!

6 replies »

  1. A critical component volume failed to capture a snapshot. A critical component volume failed to capture a snapshot. This error always happens. I am using Windows Server 2019.


  2. this won’t work on Windows 10, -hyperv is not available :
    “One of the parameters or options provided is unexpected: hyperv.”


  3. hi, hab´s gerade ausprobiert und ich glaube da ist noch ein kleiner Fehler:
    wbadmin start backup -backuptarget:\\\hyper-backup:”Server01,Server02″ -allowDeleteOldBackups -quiet
    da fehlt noch ein Attribut
    wbadmin start backup -backuptarget:\\\hyper-backup: -hyperv:”Server01,Server02″ -allowDeleteOldBackups -quiet

    lg Markus


    • Hi Markus! Vielen Dank, ja du hast recht. Fehler können passieren, wenn es allerdings der wichtigste Part ist dann ärgert mich das. Wird ausgebessert sobald ein Rechner in der Nähe ist. Lg P


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.