This script will cause Hyper-V to create backups in the folder selected, one for each day of the week.
Copy to Clipboard
$BackupPathBase = "Z:\Backups\Hyper-V"
$Date = Get-Date
#Details on command lines: https://www.nakivo.com/blog/hyper-v-export-import/
$VMList = Get-VM
foreach ( $VM in $VMList){
$BackupPath = "$($BackupPathBase)\$($Date.DayOfWeek)"
If( ! ( Test-Path -PathType container $BackupPath ) ){
New-Item -ItemType Directory -Force -Path $BackupPath
}
Write-Host "Backup up $($VM.Name) to $($BackupPath)"
Export-VM -Name $VM.Name -Path $BackupPath
}
keywords: VM, vmdx |