You are on page 1of 6

16/3/2016 UsingVeeamPowerShellSnapinforHyperVbackup

#1 Hyper-V Backup & Availability

Blog > Using Veeam PowerShell Snap-in for Hyper-V backup

Using Veeam PowerShell Snap-in for Hyper-V backup


HOME FEATURES FREE TOOLS RESOURCES BLOG WHY VEEAM PRICING CONTACT US

by Andrew Zhelezko October 29, 2015

In the first part of the article we learned what PowerShell is, when we should consider using it, and how to use basic Helpful resources:
PowerShell cmdlets. This part contains practical examples of Hyper-V backup and recovery-related operations using
PowerShell scripts with Veeam. Top 10 features for IT Pros in
Windows Server 2012 (R2) that
What is Veeam Backup PowerShell snap-in? seem to be unknown or
unloved
Since v5, Veeam Backup & Replication has had a built-in PowerShell snap-in (a package of cmdlets) that can make your
life as a backup administrator much easier. Veeam PowerShell snap-in provides a set of its own available commands,
Managing Hyper-V with
which correlate with actions that the administrator can perform in the Veeam Backup & Replication GUI. Theres no
Windows PowerShell
limit to the list of available operations; it all depends only on the administrators creativity!

Thinking about killing routine or willing to have a few one-line cmdlets handy, so you can quickly check backup
Getting stuff done with
information right from the console? Either way, this Veeam snap-in is worth knowing.
PowerShell

NOTE: All actions performed with PowerShell have the same impact as actions performed with the Veeam GUI. Once
you make a change, the change is applied to the Veeam Backup database and you may not be able undo it.

Subscribeforupdates
Getting started with Veeam PowerShell snap-in
Enteryourcorporateemail
Veeam requires PowerShell version 2.0 and newer, which should be safe for Windows Server 2008 R2 and later
releases. For older OS versions, check this manual.
SUBSCRIBE
Open the Veeam console and navigate to the main menu. Since Veeam PowerShell snap-in isnt installed by default, you
might not be able to see an available PowerShell option as shown in the figure below.

Figure 4. Veeam Backup & Replication, main menu

To add the PowerShell snap-in, follow these steps:

https://hyperv.veeam.com/blog/howtouseveeampowershellsnapinhypervbackup/ 1/6
16/3/2016 UsingVeeamPowerShellSnapinforHyperVbackup
We keep
Close theworking on bringing
Veeam Backup the most
& Replication console
interesting HyperV topics to you.
Would you please help us and suggest to the system
Put the Veeam installation disk (.iso) back
one? with the guidelines from this KB article
Modify the installation

Now you should be able to find PowerShell in the main menu and launch it.

SEND

Figure 5. Veeam Backup & Replication PowerShell Toolkit

This is a special PowerShell toolkit window with the loaded Veeam snap-in. The advantage of using it is that you wont
have to add Veeam snap-in every time youre executing the command, and some predefined cmdlets like Get-
VBRCommand are available. Toolkit is especially helpful when youd like to check something very quickly one-line
query rather than writing scripts.

Since Im about to write some scripts, Ill still be using Windows PowerShell ISE editor. Dont forget to use Add-PSSnapin
VeeamPSSnapin or asnp VeeamPSSnapin (asnp is an alias for Add-PSSnapin) command to add Veeam snap-in and click
the Refresh button so you can see that the PowerShell cmdlets available for Veeam operations.

Figure 6. Windows PowerShell ISE, module VeeamPSSnapin

NOTE: VBR stands for Veeam Backup & Replication, VSB stands for Veeam SureBackup and HV stands for Hyper-V.

Veeam PowerShell script examples


Scrolling through the list of existing Veeam cmdlets should give you an idea of possible actions to make. Ready to
experiment? Lets do it together.

It might be quite handy to check a list of VMs on any Hyper-V host added to Veeam console so we can do any operation
with a desired VM. Filter cmdlets by find and locate the cmdlet you need Find-VBRHvEntity. Once you click on it, you
see additional parameters available. Fill them in, execute the command and see how it looks properly:

FindVBRHvEntityName*Serverlocalhost

Obviously, this is too much information to show, which is why you can apply a condition to this output: place a pipe and
add Select-Object Name, Type in order to list only names of VMs and hosts.

https://hyperv.veeam.com/blog/howtouseveeampowershellsnapinhypervbackup/ 2/6
16/3/2016 UsingVeeamPowerShellSnapinforHyperVbackup

Figure 7. A list of Hyper-V VMs and hosts added to Veeam console

Now, we can use this information to perform a quick backup of a Hyper-V VM, aka VeeamZIP. For this purpose, we
should define a variable of Hyper-V object, which is done by using the name of VM. Then we complement this with the
Start-VBRZip cmdlet, as seen below:

Script to perform VeeamZIP backup of a selected Hyper-V VM:


#ToaddVeeamPowerShellsnapin
asnpVeeamPSSnapin
#DefineVirtualMachinestobackupwithVeeamZIP
$HVObject=FindVBRHvEntityServerlocalhostName'winxp'
#StartVeeamZIPjob
StartVBRZipBackupRepository"DefaultBackupRepository"Entity$HVObjectCompression5

Put it together, execute (F5) and see how Veeam is taking the VeeamZIP backup of a Hyper-V VM onto the default
backup repository (C:\backup).

This is how it looks in PowerShell editor:

Figure 8. VeeamZIP backup of selected Hyper-V VM

You can open the Veeam console and find the same operation in the GUI:

https://hyperv.veeam.com/blog/howtouseveeampowershellsnapinhypervbackup/ 3/6
16/3/2016 UsingVeeamPowerShellSnapinforHyperVbackup

Figure 9. VeeamZIP backup of selected Hyper-V VM, GUI

Note: The Start-VBRZip cmdlet is supported starting from Veeam Backup Free Edition 8.0 Update 2 and is not supported
on previous versions.

Now that we have a backup of a VM, we can restore it back to the server. Find a restore script below. Its better to read
through it from the bottom so you can understand the logic behind all variables.

Script to perform a Hyper-V VM files restore from a last backup point:


#ScripttoperformaHyperVVMfilesrestorefromalastbackuppoint
#addVeeamPowerShellSnapin
asnpVeeamPSSnapin
#defineVeeamRepositoryweredoingtherestorefrom
GetVBRBackupRepositoryname"DefaultBackupRepository"
#definethelastbackuppointoftheVM(VMname),includedtothejobWinxpbackup
$lastpoint=GetVBRBackupName"WinxpBackup"|GetVBRRestorePointNamewinxp|Sort
Object$_.creationtimeDescending|SelectFirst1
#getthelistofthefilesfromtheneededbackuppoint
$Filestorestore=GetVBRFilesInRestorePoint($lastpoint)
#definetheserverwheretoperformrestoreto
$server=GetVBRserver|where{$_.nameeq"ThisServer"}
#definethepathforrestoreontheselectedserver
$path="D:\restore"
#executerestore
StartVBRRestoreVMFilesRestorePoint$lastpointServer$serverFiles$Filestorestorepath
$path

Execute it and get Hyper-V VM files to be restored from the latest backup point to local server.

https://hyperv.veeam.com/blog/howtouseveeampowershellsnapinhypervbackup/ 4/6
16/3/2016 UsingVeeamPowerShellSnapinforHyperVbackup

Figure 10. Hyper-V VM files restore, in action

And the same process by Veeam console interface:

Figure 11. Hyper-V VM files restore, GUI

Even though, it was rather simple examples of how you can utilize PowerShell for Hyper-V backup and restore tasks, I
hope it was helpful and that it was a good starting point for your PowerShell journey. Now that youve had some
practice, feel free to practice more and check out the following resources:

Veeam Forums dedicated to PowerShell scripts


Veeam Backup Free Edition: Now with PowerShell
Learn PowerShell. From Basics to a Coding Star
The PowerShell Paradigm (live webinar)

Have a good time with PowerShell, and dont forget to share your experience with us.

See also

How to Install Veeam PowerShell Snapin


PowerShell for Veeam Backup & Replication

https://hyperv.veeam.com/blog/howtouseveeampowershellsnapinhypervbackup/ 5/6
16/3/2016 UsingVeeamPowerShellSnapinforHyperVbackup
About the author
Andrew Zhelezko is a Veeam Technical Marketing Specialist who gained a strong understanding of Veeam products by working
initially in Veeam technical support. This practical experience has helped him speak the same language as Veeam community
members. His goal is to help others realize the beauty and power of virtualization. Follow Andrew on Google+ and Spiceworks.

0Comments VeeamHyperVblog
1 Login

Recommend Share SortbyBest

Startthediscussion

Bethefirsttocomment.

ALSOONVEEAMHYPERVBLOG WHAT'STHIS?

HowtobecomeaMicrosoftCertifiedExpert,Part1 WhatisMicrosoftHyperVvirtualizationtechnology?
6commentsayearago 20commentsayearago
JosephRobertSmithMTAexamsdonotqualifyforMCP AndrewZhelezkoIdon'tthinkIfollowyouhere.Duetodrastic
certification,noraretheyaprerequisiteforMCSAorMCSE differencebetweenthose2platforms,I'dimaginethatthesteps
certification. won'tbecommonatall.Eitherway,it'sbettertomakea

UnderstandingWS2012R2virtualizationrights HowtoconfigureHyperVVirtualSwitch
18commentsayearago 8comments8monthsago
JooJooFrommyunderstanding,ifusingHyperVWS2012 WHHiAndrew...noluckwithSetVMNetworkAdapter.butI
R2STD1HyperVHost,2VMsWS2012R2DC1HyperV eventuallysucceededthismorningusingSet
Host,UnlimitedVM(CPUcapdependingonthelicenseu VMNetworkAdapterVlan....initiallythecmdletkeptfailing

Subscribe d AddDisqustoyoursiteAddDisqusAdd Privacy

FREE BACKUP TRIAL FREE BACKUP DOWNLOAD PRICING RESOURCES BLOG WHY VEEAM CONTACT US

Copyright 2016 Veeam Software. Privacy policy.

https://hyperv.veeam.com/blog/howtouseveeampowershellsnapinhypervbackup/ 6/6

You might also like