PowerShell script exchange
Post Reply
jm91
Novice
Posts: 4
Liked: never
Joined: Dec 07, 2010 7:53 am
Full Name: Jürgen Metten
Contact:

Add Job with Powershell

Post by jm91 »

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
Alexey D.

Re: Add Job with Powershell

Post by Alexey D. »

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!
gvinpin
Enthusiast
Posts: 38
Liked: never
Joined: Jan 01, 2006 1:01 am
Contact:

Re: Add Job with Powershell

Post by gvinpin »

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?
jm91
Novice
Posts: 4
Liked: never
Joined: Dec 07, 2010 7:53 am
Full Name: Jürgen Metten
Contact:

Re: Add Job with Powershell

Post by jm91 »

Hello Alexey,

it works !
Thank you for support !
Alexey D.

Re: Add Job with Powershell

Post by Alexey D. »

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.
Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests