Add Job with Powershell

PowerShell script exchange

Add Job with Powershell

Veeam Logoby jm91 » Wed May 18, 2011 10:29 am

Veeam Backup & Replication 5.0

I try to add a Backupjob with Powershell, use the following Command
> Add-VBRBackupJob -Name "Backup01" -Type VDDK -Server "svesxp02" -Folder $vbrfolder -FileName $vbrfile -Objects SVMigration
Then i receive the Message:
Add-VBRBackupJob : Cannot bind parameter 'Server'. Cannot convert the "svesxp02" value of type "System.String" to type "Veeam.Backup.Core.CHost"
.
At line:1 char:54
+ Add-VBRBackupJob -Name $vbrjobname -Type VDDK -Server <<<< "svesxp02" -Folder $vbrfolder -FileName $vbrfile -Objects SVMigration
+ CategoryInfo : InvalidArgument: (:) [Add-VBRBackupJob], Paramet
erBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Veeam.Backup.Powe
rShell.Command.AddVBRJobBackup

Anybody have an Idea ?

Greetings
JM
jm91
Novice
 
Posts: 4
Liked: never
Joined: Tue Dec 07, 2010 7:53 am
Full Name: Jürgen Metten

Re: Add Job with Powershell

Veeam Logoby Alexey D. » Wed May 18, 2011 11:46 am

Hello Jürgen,

The problem is in type casting. You're specifying String parameter, and the function needs a variable of Veeam.Backup.Core.CHost type. You should use use Get-VBRServer function to obtain an object of the requested type. Here is an example:

Code: Select all
$server = Get-VBRServer | where {$_.Name -eq "svesxp02"}

Add-VBRBackupJob -Name "Backup01" -Type VDDK -Server $server -Folder $vbrfolder -FileName $vbrfile -Objects SVMigration


Should work!
Alexey D.
 

Re: Add Job with Powershell

Veeam Logoby gvinpin » Wed May 18, 2011 9:43 pm

Alexey D. wrote:Hello Jürgen,

The problem is in type casting. You're specifying String parameter, and the function needs a variable of Veeam.Backup.Core.CHost type. You should use use Get-VBRServer function to obtain an object of the requested type. Here is an example:

Code: Select all
$server = Get-VBRServer | where {$_.Name -eq "svesxp02"}

Add-VBRBackupJob -Name "Backup01" -Type VDDK -Server $server -Folder $vbrfolder -FileName $vbrfile -Objects SVMigration


Should work!


Is this available in the manual for the product?
gvinpin
Enthusiast
 
Posts: 48
Liked: never
Joined: Sun Jan 01, 2006 1:01 am

Re: Add Job with Powershell

Veeam Logoby jm91 » Thu May 19, 2011 6:20 am

Hello Alexey,

it works !
Thank you for support !
jm91
Novice
 
Posts: 4
Liked: never
Joined: Tue Dec 07, 2010 7:53 am
Full Name: Jürgen Metten

Re: Add Job with Powershell

Veeam Logoby Alexey D. » Thu May 19, 2011 8:20 am

You're welcome, Jürgen!

Is this available in the manual for the product?


Do you mean this example? No, it was generated by one of our QA engineers and me.

The description of PowerShell functions along with list of parameters and their purposes is available via PS command line. Generic information and a couple of examples can be found via Help->Help menu item of B&R console. If you need more scripts, please search through this forum as community users contribute a lot and share various code pretty often! Hope it helps.
Alexey D.
 


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 8 guests