PowerShell script exchange
Suryanarayanan
Enthusiast
Posts: 33 Liked: 4 times
Joined: Jul 09, 2021 12:42 pm
Full Name: Suryanarayanan
Location: Bangalore India
Contact:
Post
by Suryanarayanan » Feb 26, 2026 9:04 am
this post
Hi All,
We have below automation requirements. Please suggest
Requirements:
Automate VM disk level restore from one server to another server (both are linux servers)
get the scsi id from source server
restore that disk to the target server with specific scsi id always (ex: source scsi id 0:3 adn target scsi id 0:2 always
My analysis:
using Start-VBRRestoreVirtualDisks
Below commands are to get restore points
$backup = Get-VBRBackup -Name "Backup Job name"
$restorepoint = Get-VBRRestorePoint -Backup $backup
how to get the scsi id of source server and restore it in the specific scsi id of target server?
Regards,
Surya
david.domask
Product Manager
Posts: 3369 Liked: 796 times
Joined: Jun 28, 2016 12:12 pm
Contact:
Post
by david.domask » Feb 26, 2026 9:16 am
this post
Hi Surya,
I've moved your topic to our PowerShell forums as looks like you're looking to do this with PowerShell.
Please see the examples for
Start-VBRViInstantVmDiskRecovery , it walks you through the workflow for doing an instant disk recovery to a target machine.
Once done, you can
migrate the disks to production and the restored disk will be persisted to the target VM.
David Domask | Product Management: Principal Analyst
Suryanarayanan
Enthusiast
Posts: 33 Liked: 4 times
Joined: Jul 09, 2021 12:42 pm
Full Name: Suryanarayanan
Location: Bangalore India
Contact:
Post
by Suryanarayanan » Feb 26, 2026 10:09 am
this post
Hi David,
Thanks for your reply.
Can't we do it using "Start-VBRViVirtualDiskRestore" and New-VBRViVirtualDeviceMappingRule
Regards,
Surya
david.domask
Product Manager
Posts: 3369 Liked: 796 times
Joined: Jun 28, 2016 12:12 pm
Contact:
Post
by david.domask » Feb 26, 2026 11:05 am
this post
Happy to help, Surya.
Yes, Start-VBRViVirtualDiskRestore can help here, but it doesn't support setting the target device node.
Start-VBRViInstantVmDiskRecovery let's you set the TargetVirtualDevice, and it will attach exactly as you desire in your original post, and the only additional step is to migrate the disks to production as noted in my earlier post.
I think this will better match your written needs.
David Domask | Product Management: Principal Analyst
Suryanarayanan
Enthusiast
Posts: 33 Liked: 4 times
Joined: Jul 09, 2021 12:42 pm
Full Name: Suryanarayanan
Location: Bangalore India
Contact:
Post
by Suryanarayanan » Feb 26, 2026 11:27 am
this post
Hi David,
Thanks.
Can we attach to the existing virtual device (scsi id) using Start-VBRViInstantVmDiskRecovery?
Can u help in scripting?
example:
source vm= server1
source scsi ids= 0:3, 0:4
target vm= server2
target scsi ids= 0:2, 0:3
================instant disk recovery================
$backup = Get-VBRBackup -Name "server1"
$restorepoint = Get-VBRRestorePoint
$targetserver = Get-VBRServer -Name "server2"
$device = Get-VBRViVirtualDevice -RestorePoint $restorepoint[3]
Start-VBRViInstantVMDiskRecovery -RestorePoint $restorepoint[3] -TargetVM $targetserver -TargetVirtualDevice $device
====================InstantRecoveryDiskMigration==============
$sesson = Get-VBRInstantRecovery
$backup = Get-VBRBackup -Name "server2"
$restorepoint = Get-VBRRestorePoint -Backup $backup
$disks = Get-VBRViVirtualDevice -RestorePoint $restorepoint[3]
$mapping = New-VBRViDiskMigrationMappingRule -TargetVirtualDevice $disks
Start-VBRViInstantRecoveryDiskMigration -InstantRecovery $sesson -DiskMigrationMappingRule $mapping -Force -RunAsync
===============================================
Regards,
Surya
david.domask
Product Manager
Posts: 3369 Liked: 796 times
Joined: Jun 28, 2016 12:12 pm
Contact:
Post
by david.domask » Feb 26, 2026 12:47 pm
this post
You have it mostly correct, but on your Start-VbrViInstantDiskRecovery, you need to include the
TargetVirtualDevice flag as I linked above.
You fetch the source with Get-VBRViVirtualDevice, then use
Set-VbrViVirtualDevice and set the disk settings as desired. Save the changes with Set-VbrViVirtualDevice to a variable, and pass that on the TargetVirtualDevice parameter of Start-VbrViInstantDiskRecovery.
As you have it now, it will use the device mappings from the source VM as it is in the backup.
David Domask | Product Management: Principal Analyst
Suryanarayanan
Enthusiast
Posts: 33 Liked: 4 times
Joined: Jul 09, 2021 12:42 pm
Full Name: Suryanarayanan
Location: Bangalore India
Contact:
Post
by Suryanarayanan » Feb 26, 2026 2:45 pm
this post
below script is working for me
$backup = Get-VBRBackup -Name "job name"
$restorepoint = Get-VBRRestorePoint -Backup $backup
$disks = Get-VBRViVirtualDevice -RestorePoint $restorepoint[1] | Where-Object {$_.Name -eq "server_1.vmdk"}
$server = Get-VBRServer -Name "esxihost"
$vm = Find-VBRViEntity -Server $server -Name "server2"
$device=Set-VBRViVirtualDevice -VirtualDevice $disks -ControllerNumber 0 -Type SCSI -VirtualDeviceNode 3
Start-VBRViInstantVMDiskRecovery -RestorePoint $restorepoint[1] -TargetVM $vm -TargetVirtualDevice $device
Users browsing this forum: mbjr and 10 guests