Advertisement
vPowerCLI

Veeam and Remote BE

Jan 19th, 2012
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Remoting must be enabled on the BackupExec Server
  2. # And user must have access to complete task on Veeam and BE
  3.  
  4. if ((Get-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue) -eq $null) {
  5.     Add-PsSnapin VeeamPSSnapIn
  6. }
  7.  
  8. $veeamJobName = "Main Nightly Backup"
  9. $backupExecJob = "BU Job Name"
  10. $backupExecSvr = "BackupExec01"
  11. $backupExecPath = "C:\Program Files\Symantec\Backup Exec"
  12.  
  13. if ((Get-VBRJob | ?{$_.Name -eq $veeamJobName}).GetLastResult() -eq "Success") {
  14.     $latestOib = Get-VBRBackup | ?{$_.JobName -eq $veeamJobName} | Get-VBRRestorePoint | Sort CreationTime -Descending | Select -First 1
  15.     $latestOib
  16.     $storage = $latestOib.GetStorage()
  17.     $storage.FilePath
  18.  
  19.     $file = Get-Item $storage.FilePath
  20.     if ($file.Attributes -band ([System.IO.FileAttributes]::Archive)) {  
  21.         Invoke-Command -ComputerName $backupExecSvr -ScriptBlock {
  22.             param (
  23.                 [PSObject]$storage,
  24.                 [PsObject]$file,
  25.                 [String]$backupExecJob,
  26.                 [String]$backupExecPath
  27.                 )
  28.            
  29.             & "$backupExecPath\bemcmd.exe" -o2 -j:$backupExecJob -s:$storage.FilePath -m Tapes-Weekdays -r -w
  30.             $file.Attributes = 'Archive'
  31.         } -ArgumentList $storage, $file, $backupExecJob, $backupExecPath
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement