PowerShell script exchange
anthony.tiley
Lurker
Posts: 1 Liked: never
Joined: May 25, 2022 7:52 am
Full Name: Anthony
Contact:
Post
by anthony.tiley » May 25, 2022 8:13 am
this post
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: 2123 Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:
Post
by david.domask » May 25, 2022 10:37 am
this post
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
Users browsing this forum: No registered users and 11 guests