Working with Hyper-V Virtual Lab
This example shows how to create a virtual lab and perform other actions on virtual labs from your command line.
Create a virtual lab
To add a virtual lab, you will need to perform the following steps:
- Get the Hyper-V host on which you want to create the virtual lab with Get-VBRServer and save it to a variable.
- Run Add-VSBHvVirtualLab with this variable to create the virtual lab.
# Get the host:
$host = Get-VBRServer -Type Hyper-V
# Create the virtual lab:
Add-VSBHvVirtualLab -Name "Microsoft Exchange Vlab" -Server $server -Folder "c:\VirtualLabs"
Remove the virtual lab
If you no longer need a virtual lab, you can remove it.
To remove a virtual lab, you will need to perform the following steps:
- Get the virtual lab that you want to remove with Get-VSBHvVirtualLab.
- Run Remove-VSBHvVirtualLab to remove it.
# Get the virtual lab and pipe it down:
Get-VSBHvVirtualLab -Name "Microsoft Exchange Vlab" | Remove-VSBHvVirtualLab
Connect an existing virtual lab
If you have virtual labs that are not added to your Veeam backup console, you can look for them and connect them.
You will need to perform the following steps:
- Run Find-VSBHvVirtualLab to look for the virtual lab. You will need to get the host where it is located first.
- Add them with Connect-VSBHvVirtualLab.
Note that the Find-VSBHvVirtualLab cmdlet can be used only to look for the virtual labs that are not connected to the Veeam backup server. You can use the objects that you obtain with it only with the Connect-VSBHvVirtualLab cmdlet. For all other purposes, run Get-VSBHvVirtualLab.
# Find the virtual lab:
$newvlab = Get-VBRServer -Type HvServer | Find-VSBHvVirtualLab -Name "Virtual Lab 02"
# Connect the virtual lab:
Connect-VSBHvVirtualLab -VirtualLab $newvlab