PowerShell script exchange
Post Reply
anthony.tiley
Lurker
Posts: 1
Liked: never
Joined: May 25, 2022 7:52 am
Full Name: Anthony
Contact:

Automating restoring disks to a second server

Post by anthony.tiley »

I have created a script for the restoration of disks from VM-A to a VM-B, however upon running it prompts to allow the overwriting of the existing disks on VM-B. It has a few disks, and prompts inbetween each disk. I was hoping to automate this so that every set amount of days, it restores from VM-A to VM-B, without the need for any interaction. Is there a way to silence the pop ups?

Script as below (names generalised)...

Code: Select all

$backup = "BackupJob"
$promrestorepoint = Get-VBRBackup -Name "BackupJob" | Get-VBRRestorePoint -Name VM-A | Select-Object -Last 1
$promdisks = Get-VBRViVirtualDevice -RestorePoint $promrestorepoint
$server = Get-VBRServer -Name "VMHost"
$promlabserver = Find-VBRViEntity -DatastoresAndVMs -Server $server -Name VM-B"
foreach ($disk in $promdisks) {
$prommappingrule = New-VBRViVirtualDeviceMappingRule -SourceVirtualDevice $disk
if ($disk -eq $promdisks[-1]) {
Start-VBRViVirtualDiskRestore -RestorePoint $promrestorepoint -VirtualDeviceMapping $prommappingrule -TargetVM $promlabserver[0] -Reason Sandbox -PowerOn
} else {
Start-VBRViVirtualDiskRestore -RestorePoint $promrestorepoint -VirtualDeviceMapping $prommappingrule -TargetVM $promlabserver[0] -Reason Sandbox
}
}
I'm by no means a scripting expert... I just want to silence or automatically accept the prompts that appear for the overwriting of disks on VM-B
david.domask
Veeam Software
Posts: 1246
Liked: 326 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Automating restoring disks to a second server

Post by david.domask »

Hi @anthony.tiley, I've not tried it, but does the -Force parameter help you here?

Edit: just tested, went without confirmation with -Force.
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests