Hi everyone,
I'm trying to set up Windows Server Backup on a Hyper-V Server 2016 via PowerShell but always receive an error.
Here's my code:
$Policy = New-WBPolicy
Set-WBSchedule -Policy $Policy -Schedule 22:00
$Credentials = Get-Credential
$Location = New-WBBackupTarget -NetworkPath "\\NAS\Backup" -Credential $Credentials
Add-WBBackupTarget -Policy $Policy -Target $Location
$Volumes = Get-WBVolume -CriticalVolumes
Add-WBVolume -Policy $Policy -Volume $Volumes
$VHDX = New-WBFileSpec -FileSpec "C:\*.vhdx" -Exclude
$VHD = New-WBFileSpec -FileSpec "C:\*.vhd" -Exclude
$ISO = New-WBFileSpec -FileSpec "C:\*.iso" -Exclude
$Temp = New-WBFileSpec -FileSpec "C:\Windows\Temp" -Exclude
$SoftwareDistribution = New-WBFileSpec -FileSpec "C:\Windows\SoftwareDistribution" -Exclude
$catroot2 = New-WBFileSpec -FileSpec "C:\Windows\System32\catroot2" -Exclude
Add-WBFileSpec -Policy $Policy $VHDX,$VHD,$ISO,$Temp,$SoftwareDistribution,$catroot2
$VirtualMachines = Get-WBVirtualMachine
Add-WBVirtualMachine -Policy $Policy -VirtualMachine $VirtualMachines
Add-WBBareMetalRecovery -Policy $Policy
Add-WBSystemState -Policy $Policy
Set-WBVssBackupOption -Policy $Policy -VssFullBackup
The value of $Policy
:
Schedule : {14.09.2021 22:00:00}
BackupTargets : {\\NAS01\Backup}
VolumesToBackup : {OS (C:)}
FilesSpecsToBackup : {}
FilesSpecsToExclude : {C:\*.vhdx, C:\*.vhd, C:\*.iso, C:\Windows\Temp\*...}
ComponentsToBackup : {VM01, VM02, Host Component}
BMR : True
SystemState : True
OverwriteOldFormatVhd : True
VssBackupOptions : VssFullBackup
If I run Start-WBBackup -Policy $Policy -Async
, the backup process runs just fine and I can see the files being created in the target location.
However, if I try to apply the configuration for scheduling via Set-WBPolicy -Policy $Policy -AllowDeleteOldBackups -Verbose
, the error stated is simply "wrong parameter".
Any ideas what's wrong?