PowerShell script exchange
Post Reply
jkcouch
Enthusiast
Posts: 30
Liked: never
Joined: Jun 26, 2011 7:02 pm
Full Name: Jeff Couch
Contact:

Veeam 6 Vmattribute powershell question

Post by jkcouch »

How can I set my job notification options in Veeam 6 with powershell? I used to this this:

Code: Select all

vbrjob = Get-VBRJob | where {$_.name -eq $job.JobName}
$options = $vbrjob.GetOptions() 
$options.VmAttributeName = "Veeam"
$options.SetResultsToVmNotes = $true
$vbrjob.SetOptions($options)
Now since its broken out differently I cannot find the place to set the attribute since when you run this:

Code: Select all

vbrjob = Get-VBRJob | where {$_.name -eq $job.JobName}
$options = $vbrjob.GetOptions()
$options.NotificationOptions | gm
You get:
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
EmailNotification Property System.Boolean EmailNotification {get;set;}
EmailNotificationAddresses Property System.String EmailNotificationAddresses {get;set;}
SnmpNotification Property System.Boolean SnmpNotification {get;set;}


There are no options for setting the vmattributename. Is it hidden somewhere else or left out of 6.0? I see it in $options.Options.RootNode, but am unable to set it there.

Thanks in advance.
Sethbartlett
Veteran
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Veeam 6 Vmattribute powershell question

Post by Sethbartlett »

Here you go:

Code: Select all

$job = Get-VBRJob | ?{$_.name -eq "MyJob"}
$opt = $job.GetOptions()
$opt.ViSourceOptions.VmAttributeName = "whatever you want"
$opt.SetResultsToVmNotes = $true
$job.SetOptions($opt)
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.
Gostev
Chief Product Officer
Posts: 31459
Liked: 6648 times
Joined: Jan 01, 2006 1:01 am
Location: Baar, Switzerland
Contact:

Re: Veeam 6 Vmattribute powershell question

Post by Gostev »

Seth,

Code: Select all

{$_.name -eq "MyJob"}
is really old style with v6 though ;)

I heard there is now -Name parameter in every cmdlet now, can you confirm it works?
jkcouch
Enthusiast
Posts: 30
Liked: never
Joined: Jun 26, 2011 7:02 pm
Full Name: Jeff Couch
Contact:

Re: Veeam 6 Vmattribute powershell question

Post by jkcouch »

HA! Thanks Seth. I found it this morning and was coming back to post it.

Gostev, yes it does work. Aswesome!

Code: Select all

get-vbrjob -name "MyJob" 
Gostev
Chief Product Officer
Posts: 31459
Liked: 6648 times
Joined: Jan 01, 2006 1:01 am
Location: Baar, Switzerland
Contact:

Re: Veeam 6 Vmattribute powershell question

Post by Gostev »

Haha, this is officially the first time that I am teaching Seth something on our PowerShell capabilities (and not the other way around!)
Sethbartlett
Veteran
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Veeam 6 Vmattribute powershell question

Post by Sethbartlett »

Haha! Very true, very awesome! I never did a Get-VBRJob -? or any help on the cmdlets once I learned them the first time. Now I'll have to check them all :) Thanks.
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.
jteager
Influencer
Posts: 10
Liked: never
Joined: Mar 28, 2011 2:13 pm
Full Name: Justin Teager
Contact:

Re: Veeam 6 Vmattribute powershell question

Post by jteager »

I do wish I didn't have to put "-name" at all though. Not like get-vbrjob really takes any other parameters :P
Gostev
Chief Product Officer
Posts: 31459
Liked: 6648 times
Joined: Jan 01, 2006 1:01 am
Location: Baar, Switzerland
Contact:

Re: Veeam 6 Vmattribute powershell question

Post by Gostev »

Is it even acceptable by PowerShell syntax best practices to omit parameter name?
ThomasMc
Veteran
Posts: 293
Liked: 19 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: Veeam 6 Vmattribute powershell question

Post by ThomasMc »

You can omit the name if the cmdlet parameter is positional but the ones in Veeam are named
Good cmdlet design recommends that the most-used parameters be declared as positional parameters so that the user does not have to enter the parameter name when the cmdlet is run.
MSDN Source
jteager
Influencer
Posts: 10
Liked: never
Joined: Mar 28, 2011 2:13 pm
Full Name: Justin Teager
Contact:

Re: Veeam 6 Vmattribute powershell question

Post by jteager »

Ooh, cool doc. Thanks Thomas! As someone who actually does some C# on the side, I didn't even know that suite of info existed. Quite handy ;)
Sethbartlett
Veteran
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Veeam 6 Vmattribute powershell question

Post by Sethbartlett »

Agreed Thomas, positional should be done. So we can do Get-VBRServer "serverName", Get-VBRJob "JobName", etc, etc.
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.
jteager
Influencer
Posts: 10
Liked: never
Joined: Mar 28, 2011 2:13 pm
Full Name: Justin Teager
Contact:

Re: Veeam 6 Vmattribute powershell question

Post by jteager »

It'd also be cool if -Name accepted wildcards... ;)
Gostev
Chief Product Officer
Posts: 31459
Liked: 6648 times
Joined: Jan 01, 2006 1:01 am
Location: Baar, Switzerland
Contact:

Re: Veeam 6 Vmattribute powershell question

Post by Gostev »

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

Re: Veeam 6 Vmattribute powershell question

Post by Sethbartlett »

Such a troll...Haha, but you're right it does :D. FYI, the help documentation(Get-help Get-VbrJob -full) states that it doesn't accept wildcards :wink:
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.
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests