Veeam 6 Vmattribute powershell question

PowerShell script exchange

Veeam 6 Vmattribute powershell question

Veeam Logoby jkcouch » Fri Dec 02, 2011 10:11 pm

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.
jkcouch
Enthusiast
 
Posts: 30
Liked: never
Joined: Sun Jun 26, 2011 7:02 pm
Full Name: Jeff Couch

Re: Veeam 6 Vmattribute powershell question

Veeam Logoby Sethbartlett » Sat Dec 03, 2011 12:39 am

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.
Sethbartlett
Expert
 
Posts: 282
Liked: 25 times
Joined: Wed Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett

Re: Veeam 6 Vmattribute powershell question

Veeam Logoby Gostev » Sat Dec 03, 2011 10:30 am

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?
Gostev
Veeam Software
 
Posts: 21390
Liked: 2349 times
Joined: Sun Jan 01, 2006 1:01 am
Location: Baar, Switzerland

Re: Veeam 6 Vmattribute powershell question

Veeam Logoby jkcouch » Sat Dec 03, 2011 4:20 pm

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"
jkcouch
Enthusiast
 
Posts: 30
Liked: never
Joined: Sun Jun 26, 2011 7:02 pm
Full Name: Jeff Couch

Re: Veeam 6 Vmattribute powershell question

Veeam Logoby Gostev » Sat Dec 03, 2011 4:50 pm

Haha, this is officially the first time that I am teaching Seth something on our PowerShell capabilities (and not the other way around!)
Gostev
Veeam Software
 
Posts: 21390
Liked: 2349 times
Joined: Sun Jan 01, 2006 1:01 am
Location: Baar, Switzerland

Re: Veeam 6 Vmattribute powershell question

Veeam Logoby Sethbartlett » Mon Dec 05, 2011 12:20 am

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.
Sethbartlett
Expert
 
Posts: 282
Liked: 25 times
Joined: Wed Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett

Re: Veeam 6 Vmattribute powershell question

Veeam Logoby jteager » Tue Dec 06, 2011 10:56 pm

I do wish I didn't have to put "-name" at all though. Not like get-vbrjob really takes any other parameters :P
jteager
Veeam Software
 
Posts: 10
Liked: never
Joined: Mon Mar 28, 2011 2:13 pm
Full Name: Justin Teager

Re: Veeam 6 Vmattribute powershell question

Veeam Logoby Gostev » Tue Dec 06, 2011 11:19 pm

Is it even acceptable by PowerShell syntax best practices to omit parameter name?
Gostev
Veeam Software
 
Posts: 21390
Liked: 2349 times
Joined: Sun Jan 01, 2006 1:01 am
Location: Baar, Switzerland

Re: Veeam 6 Vmattribute powershell question

Veeam Logoby ThomasMc » Tue Dec 06, 2011 11:32 pm

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
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: Veeam 6 Vmattribute powershell question

Veeam Logoby jteager » Tue Dec 06, 2011 11:59 pm

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 ;)
jteager
Veeam Software
 
Posts: 10
Liked: never
Joined: Mon Mar 28, 2011 2:13 pm
Full Name: Justin Teager

Re: Veeam 6 Vmattribute powershell question

Veeam Logoby Sethbartlett » Wed Dec 07, 2011 1:46 am

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.
Sethbartlett
Expert
 
Posts: 282
Liked: 25 times
Joined: Wed Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett

Re: Veeam 6 Vmattribute powershell question

Veeam Logoby jteager » Wed Dec 07, 2011 4:47 pm

It'd also be cool if -Name accepted wildcards... ;)
jteager
Veeam Software
 
Posts: 10
Liked: never
Joined: Mon Mar 28, 2011 2:13 pm
Full Name: Justin Teager

Re: Veeam 6 Vmattribute powershell question

Veeam Logoby Gostev » Wed Dec 07, 2011 9:30 pm

Gostev
Veeam Software
 
Posts: 21390
Liked: 2349 times
Joined: Sun Jan 01, 2006 1:01 am
Location: Baar, Switzerland

Re: Veeam 6 Vmattribute powershell question

Veeam Logoby Sethbartlett » Wed Dec 07, 2011 9:32 pm

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.
Sethbartlett
Expert
 
Posts: 282
Liked: 25 times
Joined: Wed Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 14 guests