PowerShell script exchange
pizzim13
Enthusiast
Posts: 94
Liked: 6 times
Joined: Apr 21, 2011 7:37 pm
Contact:

Change job description field via powershell

Post by pizzim13 »

Is it possible to change the description field of a job via powershell. Currently, I see it as read only.

Code: Select all

PS C:\> $(Get-VBRJob)[0].description = "test"
"Description" is a ReadOnly property.
At line:1 char:18
+ $(Get-VBRJob)[0]. <<<< description = "test"
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException
Sethbartlett
Veteran
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Change job description field via powershell

Post by Sethbartlett »

I am currently looking into a way to see if this is doable or how we can get this done for you.
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
Veteran
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Change job description field via powershell

Post by Sethbartlett »

The way to do this is a little odd...but what you can do is the following:

Code: Select all

$job = Get-VBRJob | ?{$_.name -eq "JobName"}
$job.info.Update("jobname", "description")
[Veeam.Backup.Core.CBackupJob]::Update($job.info)
$Job.Info.Update requires 2 arguments, the jobname and the description. This will allow you to set the job description and change the job name of your job.

This means if you want to just change the description, that line would be

Code: Select all

$job.info.update($job.Name, "Description text")
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: 31746
Liked: 7250 times
Joined: Jan 01, 2006 1:01 am
Location: Baar, Switzerland
Contact:

Re: Change job description field via powershell

Post by Gostev »

What a dirty hack Seth ;) this is not really a supported way, for example changing the job name this way can screw up a lot of things.
Right now there is no supported way to set description through API (use the above at your own risk), but I've asked to add this to v6.
Sethbartlett
Veteran
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Change job description field via powershell

Post by Sethbartlett »

Completely agreed, I would never use this to change the name of a job :) Powershell is a little too powerful and lets you have duplicates names with your jobs, which is a no no :)
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.
Andreas Neufert
VP, Product Management
Posts: 7052
Liked: 1498 times
Joined: May 04, 2011 8:36 am
Full Name: Andreas Neufert
Location: Germany
Contact:

Re: Change job description field via powershell

Post by Andreas Neufert »

@Gostev Hi Anton, I can´t find it in v6. Do you have an idea where to find this? Need this for a customer. Thanks in advance ... CU Andy
chrmol
Enthusiast
Posts: 38
Liked: 2 times
Joined: May 17, 2010 7:41 pm
Full Name: Christian Moeller
Location: Denmark
Contact:

Re: Change job description field via powershell

Post by chrmol »

Is it possible to change the content of "description" field in powershell with Veeam 6.5 (in a supported way :D ) ?
reaperhammer
Service Provider
Posts: 27
Liked: 9 times
Joined: Aug 18, 2016 7:59 pm
Full Name: Will S
Contact:

Re: Change job description field via powershell

Post by reaperhammer »

Veeam Logoby Andreas Neufert » Sun Apr 15, 2012 8:21 pm
@Gostev Hi Anton, I can´t find it in v6. Do you have an idea where to find this? Need this for a customer. Thanks in advance ... CU Andy
Any update on this feature?
fdecome
Service Provider
Posts: 8
Liked: never
Joined: Oct 13, 2017 1:58 pm
Full Name: DECOME Fabrice
Contact:

Re: Change job description field via powershell

Post by fdecome »

Hello,
Any update for this features ?
Regard's
veremin
Product Manager
Posts: 20360
Liked: 2287 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Change job description field via powershell

Post by veremin »

You can change a job name, using the following script.

Code: Select all

$Job = Get-VBRJob "Name of your Job"
$Job.Info.CommonInfo.Name = "New Name"
$Job.Update()
However, we haven't found an easy way to change a job description:

Thanks.
Vek17
Service Provider
Posts: 49
Liked: 15 times
Joined: May 29, 2018 8:42 pm
Contact:

Re: Change job description field via powershell

Post by Vek17 »

I have come up with a way to modify description but I haven't done a full look to see if there are any unwanted side effects/issues. Any gotchas I should be on the lookout for?

Code: Select all

$updatedInfo = [Veeam.Backup.Model.CDbBackupJobInfo]::CreateNew(
    $Job.Info.ID, 
    [Veeam.Backup.Model.CDbJobCommonInfo]::new($Job.Info.CommonInfo.Name,"NEW DESCRIPTION HERE",$Job.Info.CommonInfo.ModifiedBy), 
    $Job.Info.jobType, 
    $Job.Info.targetHostId, 
    $Job.Info.targetDir, 
    $Job.Info.targetFile, 
    $Job.Info.options, 
    $Job.Info.ScheduleOptions, 
    $Job.Info.vssOptions, 
    $Job.Info.vcbHostId, 
    $Job.Info.SourceType, 
    $Job.Info.targetType, 
    $Job.Info.includedSize, 
    $Job.Info.excludedSize, 
    $Job.Info.BackupPlatform, 
    $Job.Info.targetRepositoryId, 
    $Job.Info.InitialRepositoryId, 
    $Job.Info.parentScheduleId, 
    $Job.Info.pwdKeyId, 
    $Job.Info.BackupPolicyTag, 
    $Job.Info.sqlEnabled, 
    $Job.Info.oracleEnabled
)
[Veeam.Backup.Core.CBackupJob]::Update($updatedInfo)
veremin
Product Manager
Posts: 20360
Liked: 2287 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Change job description field via powershell

Post by veremin »

Nothing from the top of my head. However, if I were you, I would:

- clone existing job
- change description on it, using the script provided
- execute the job once or twice
- check whether everything works as expected
- and based on results, stick to the script for the original job

Might be an overkill, but it's better to be on the safe side.

Thanks!
masonit
Service Provider
Posts: 327
Liked: 23 times
Joined: Oct 09, 2012 2:30 pm
Full Name: Maso
Contact:

Re: Change job description field via powershell

Post by masonit »

Hi

Any supported way now?

\Masonit
veremin
Product Manager
Posts: 20360
Liked: 2287 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Change job description field via powershell

Post by veremin »

Nothing has changed for this matter since my last reply. Thanks!
masonit
Service Provider
Posts: 327
Liked: 23 times
Joined: Oct 09, 2012 2:30 pm
Full Name: Maso
Contact:

Re: Change job description field via powershell

Post by masonit »

Ok, not good to not be able to set description in a supported way with ps. Should I create a change request for this?

\Maso
veremin
Product Manager
Posts: 20360
Liked: 2287 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Change job description field via powershell

Post by veremin » 1 person likes this post

Posting here is enough, we will keep an eye on this request, while planing PowerShell enhancements in future product versions. Thanks!
jjlethiers
Service Provider
Posts: 13
Liked: 1 time
Joined: Apr 11, 2016 9:55 am
Full Name: Jean-Jacques Lethiers
Contact:

Re: Change job description field via powershell

Post by jjlethiers »

One more vote!
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 669 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Change job description field via powershell

Post by oleg.feoktistov »

Thanks, @jjlethiers. Noted your vote.
masonit
Service Provider
Posts: 327
Liked: 23 times
Joined: Oct 09, 2012 2:30 pm
Full Name: Maso
Contact:

Re: Change job description field via powershell

Post by masonit »

Hi

Any update in this in version 10?

\Masonit
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 669 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Change job description field via powershell

Post by oleg.feoktistov »

Not as of now. But I remember about it.
Let me see if it can make it through to v11.
stuart_little1874
Influencer
Posts: 22
Liked: 4 times
Joined: Jul 22, 2020 1:25 pm
Full Name: Stuart Little
Contact:

Re: Change job description field via powershell

Post by stuart_little1874 »

Another vote here too. I have a significant deployment for a customer and being able to script this would be a real advantage
masonit
Service Provider
Posts: 327
Liked: 23 times
Joined: Oct 09, 2012 2:30 pm
Full Name: Maso
Contact:

Re: Change job description field via powershell

Post by masonit »

Hi!

Will this be available in v11?

\Magnus
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 669 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Change job description field via powershell

Post by oleg.feoktistov » 1 person likes this post

Hi,

Not in v11, but I remember about this request.

Thanks,
Oleg
anpa
Service Provider
Posts: 31
Liked: 12 times
Joined: Oct 27, 2011 8:42 am
Full Name: Andreas Cederlund
Location: Landskrona, Sweden
Contact:

Re: Change job description field via powershell

Post by anpa »

I'd like to cast my vote for this as well, would make it a lot easier for us!

/Andreas
mytsk
Service Provider
Posts: 4
Liked: never
Joined: Oct 02, 2018 2:20 pm
Full Name: Martin

Re: Change job description field via powershell

Post by mytsk »

Topic is less that two weeks away from turning 10 years an still not able to update description. In the era of automation please get this most suitable attribute writeable through automation.
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 669 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Change job description field via powershell

Post by oleg.feoktistov »

Hi Martin,

Though the topic is almost 10 years old, it doesn't mean we don't watch after it. Beside the fact that it is not a high-priority feature, the way of setting properties for many old classes like CBackupJob complicates the implementation. It might look easy from the first sight - we just make Description property writable directly or through -Description parameter in Set-VBRJobOptions cmdlet and "welcome to the new era". But the problem is that for many types of jobs Add/Set cmdlets are mapped directly to the core classes. It implies no fixed API contract, and if some logic changes on the backend, it can affect properties/methods etc. of these classes. We have already encountered such issues when getting NextRun property for CBackupJob and CachedFreeSpace/CachedTotalSpace properties for CBackupRepository class.

So, in the end, it's not just about single property, but rather about a new set of cmdlets mapped to separate PS classes with proper fixed API like Set-VBRComputerBackupJob has. We are leaning towards that approach now.

Thanks,
Oleg
mytsk
Service Provider
Posts: 4
Liked: never
Joined: Oct 02, 2018 2:20 pm
Full Name: Martin

Re: Change job description field via powershell

Post by mytsk »

Oleg,

Thanks for going in to detail and explaining the root issue, appreciate it.
M4rco
Service Provider
Posts: 49
Liked: 3 times
Joined: Apr 20, 2015 7:23 pm
Contact:

Re: Change job description field via powershell

Post by M4rco »

+1 for the feature request to allow manipulation of the description field using Powershell!

We use more and more automation on our Veeam setup to force standardization, we need to write the description field with information which helps our Veeam operators in avoiding making mistakes.
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 669 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Change job description field via powershell

Post by oleg.feoktistov »

Thanks, noted. It'd be a whole other cmdlet though.
@IT_Guru
Novice
Posts: 4
Liked: never
Joined: Jan 22, 2019 3:50 pm
Full Name: Bill Bednarzyk
Contact:

Re: Change job description field via powershell

Post by @IT_Guru »

No methods available for us to change the description on a backup job with Powershell?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest