PowerShell script exchange
Alexey D.

Re: powershell cmdlets

Post by Alexey D. »

pavan.penmetsa wrote:Hello,
Can anyone let me know what we need to pass to the following commandlet as argument.

get-VSBTaskSession -session "?"
Hello Pavan,

Please try this:

Code: Select all

Get-VSBSession | {filter here} | Get-VSBTaskSession 

sidavid
Enthusiast
Posts: 63
Liked: 1 time
Joined: Jan 01, 2006 1:01 am
Contact:

Powershell Veeam Set-VBRJobOptions

Post by sidavid »

[merged]

Hi

I want to create a script to backup more than 100VMs. My Set-VBRJobOptions command is not working. Here is my script:

$job = $vbrjobname
Set-VBRJobOptions ($job) -EmailNotification $true
Set-VBRJobOptions ($job) -RetainCycles 2
Set-VBRJobOptions ($job) -CompressionLevel 4
$job.Save()

I have Veeam version 5

Thanks

ds

Vitaliy S.
Product Manager
Posts: 24341
Liked: 1888 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: powershell cmdlets

Post by Vitaliy S. »

Please take a look at the first pages of this thread for some examples of this cmdlet, should help.

Sethbartlett
Expert
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: powershell cmdlets

Post by Sethbartlett »

You would need to do something like the following:

Code: Select all

$Job = Get-VBRJob | ?{$_.name -eq "JobName"}
Then you can do the Set-VBRJobOptions. You cannot simply give Get-VBRJob or JobOptions a string(Job Name), it requires an object and is more .NET appropriate.
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.

sidavid
Enthusiast
Posts: 63
Liked: 1 time
Joined: Jan 01, 2006 1:01 am
Contact:

Re: powershell cmdlets

Post by sidavid »

Hi
I tried this
$job = Get-VBRJob | ?{$_.name -eq "Lab"}
Set-VBRJobOptions ($job) -EmailNotification $true

And I receive the following error:

PS C:\Documents and Settings\Administrator\Desktop> .\test2.ps1
Set-VBRJobOptions : A parameter cannot be found that matches parameter name 'Em
ailNotification'.
At C:\Documents and Settings\Administrator\Desktop\test2.ps1:2 char:44
+ Set-VBRJobOptions ($job) -EmailNotification <<<< $true
+ CategoryInfo : InvalidArgument: (:) [Set-VBRJobOptions], Parame
terBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Veeam.Backup.PowerShell.C
ommand.SetVBRJobOptions

Thanks to all

sidavid
Enthusiast
Posts: 63
Liked: 1 time
Joined: Jan 01, 2006 1:01 am
Contact:

Re: powershell cmdlets

Post by sidavid »

Hi
I still have the issue and I'm blocked with this error.
Thanks for your help

htwnrva
Enthusiast
Posts: 32
Liked: never
Joined: Jan 20, 2010 6:59 pm
Full Name: Ronny
Contact:

Re: powershell cmdlets

Post by htwnrva »

Hi I am having the same issues using 5.0.2 also. I get

PS Set-VBRJobOptions ($job) -EmailNotification $true
Set-VBRJobOptions : A parameter cannot be found that matches parameter name 'Em
ailNotification'.
At line:1 char:44
+ Set-VBRJobOptions ($job) -EmailNotification <<<< $true
+ CategoryInfo : InvalidArgument: (:) [Set-VBRJobOptions], Parame
terBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Veeam.Backup.PowerShell.C
ommand.SetVBRJobOptions

Any ideas?

ThomasMc
Expert
Posts: 293
Liked: 18 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: powershell cmdlets

Post by ThomasMc »

Is this what you are looking for?

Code: Select all

$job = Get-VBRJob | ?{$_.name -eq "JobName"}
$vo = $job.GetOptions()
$vo.EmailNotification = $true
$job.SetOptions($vo)

Not sure why the $job.Save() doesn't work but it does update the job checkbox without it

jteager
Influencer
Posts: 10
Liked: never
Joined: Mar 28, 2011 2:13 pm
Full Name: Justin Teager
Contact:

Re: powershell cmdlets

Post by jteager »

The $job.SetOptions($opt) command will implicitly save the job when run with a valid parameter, so .Save() is unnecessary in this circumstance.

ThomasMc
Expert
Posts: 293
Liked: 18 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: powershell cmdlets

Post by ThomasMc »

Ah right, thanks for that Justin.

sidavid
Enthusiast
Posts: 63
Liked: 1 time
Joined: Jan 01, 2006 1:01 am
Contact:

Re: powershell cmdlets

Post by sidavid »

Hi,
How can I change the backup mode to Reversed Incremental? What is the property name?
Many Thanks
DS

Vitaliy S.
Product Manager
Posts: 24341
Liked: 1888 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: powershell cmdlets

Post by Vitaliy S. »

Hello sidavid,

You can export existing job via Get-VBRJob | Export-VBRJob PowerShell command to review job configuration settings in XML file, should help to locate all the properties.

Hope this helps!

sidavid
Enthusiast
Posts: 63
Liked: 1 time
Joined: Jan 01, 2006 1:01 am
Contact:

Re: powershell cmdlets

Post by sidavid »

Hi

This is exactly what I'm looking for.

Thanks

sidavid
Enthusiast
Posts: 63
Liked: 1 time
Joined: Jan 01, 2006 1:01 am
Contact:

Re: powershell cmdlets

Post by sidavid »

Hi,

I have created a script that get all Vms in a directory, but I have a small issue, the virtual machines are not added to the job.

Add-PSSnapin "VeeamPSSnapIn"
Add-pssnapin VMware.VimAutomation.Core
Connect-VIServer 192.168.1.10
get-folder "Temp" | get-vm | foreach {$v = $_.name
$vbrserver = Get-VBRServer | Where {$_.Type -eq "Local"}
$vbrjobname = $v
$vbrfolder = "C:\BACK\" + $v
$vbrfile = $v + ".vbk"
$vbrobjects = $v
Add-VBRBackupJob -Name $vbrjobname -Type VDDK -Server $vbrserver -Folder $vbrfolder -FileName $vbrfile -Objects $vbrobjects
}

The job is created but Objects in job 0, I'm running vcenter 4.1

Thanks

DS

Vitaliy S.
Product Manager
Posts: 24341
Liked: 1888 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: powershell cmdlets

Post by Vitaliy S. »

Hi, please look through this topic where there is an "add VM" example script: Remove-VBRJobObject (nevermind the title)

ThomasMc
Expert
Posts: 293
Liked: 18 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: powershell cmdlets

Post by ThomasMc »

You may also want $v to be an array because you just keep overwriting it

Code: Select all

Get-Folder "Temp" | Get-VM | ForEach { $v += @($_.Name) }
Actually thinking about what your trying to do, it wouldn't work in a array after look at the code below the Get-Folder, might I suggest you;

1) create the job without any objects
2) Move the Get-Folder cmd below your Add-VBRJob and change your ForEach to use the Add-VBRJobObject cmdlet(or use the function below)

Code: Select all

function Add-JO{
  Param ([string]$vmname,[string]$jobname)
  $newjob =  Get-VBRJob | ?{$_.Name -eq "$jobname"}
  $vbrserver = Get-VBRServer | ?{$_.Type -eq "VC"}
  Add-VBRJobObject -Job $newjob -Server $vbrserver -Object $vmname
}
and to call you would use

Code: Select all

Add-JO "vm01.lab.local" "VM01 Backup Job Name"

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests