Advertisement
vPowerCLI

Veeam v5 - Backup single VM in Job

Jan 14th, 2012
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #* Load Veeam snapin
  2. asnp VeeamPSSnapin -ErrorAction SilentlyContinue
  3.  
  4. #* User Input
  5. $jobName = Read-Host "Enter Job Name"
  6. $vmName = Read-Host "Enter VM Name"
  7.  
  8. #* Find the job that has our VM
  9. $job = Get-VBRJob | ?{$_.Name -eq $jobName}
  10.  
  11. #* Get all objects in job apart from our target VM
  12. $execObjs = $job.GetObjectsInJob() | ?{$_.Name -ne $vmName}
  13.  
  14. #* Exclude the objects from the job(*Note: this isn't removing the objects
  15. #* from the job)
  16. Remove-VBRJobObject -Job $job -Objects $execObjs
  17.  
  18. #* Start the job only backing up the target VM
  19. Start-VBRJob -Job $job
  20.  
  21. #* Find the exclude job objects
  22. $incObjs = $job.GetObjectsInJob() | ?{$_.Type -eq "Exclude"}
  23.  
  24. #* Delete the exclude objects(*Note: this tells VBR to include them again
  25. foreach ($obj in $incObjs) {
  26.    $obj.Delete()
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement