PowerShell script exchange
Post Reply
nd39475
Enthusiast
Posts: 58
Liked: 7 times
Joined: May 05, 2016 6:28 pm
Full Name: n d
Contact:

powershell reference / lack of detail

Post by nd39475 »

re: https://helpcenter.veeam.com/docs/backu ... ml?ver=120

where can i find a list of the "options" for the cmdlet?

i know i can do something like this

Code: Select all

$Options = Get-VBRJob -Name "$NewCopyJobName" | Get-VBRJobOptions
$Options.GenerationPolicy.SimpleRetentionRestorePoints = 90
but i'm looking to convert that to days, not RP's.
Of course, a complete list would be very helpful.
ronnmartin61
Veeam Software
Posts: 441
Liked: 131 times
Joined: Mar 07, 2016 3:55 pm
Full Name: Ronn Martin
Contact:

Re: powershell reference / lack of detail

Post by ronnmartin61 »

I'm sure there's a fancy Powershell way to query but generally I'd just run that first line of code and then type "$Options." in my Powershell host window and let Intellisense tell me what properties and methods were available.
nd39475
Enthusiast
Posts: 58
Liked: 7 times
Joined: May 05, 2016 6:28 pm
Full Name: n d
Contact:

Re: powershell reference / lack of detail

Post by nd39475 »

Thank you, by intellesense i presume you mean the autocomplete like feature? well, it does nothing.

i did find variables with `$options.GenerationPolicy` enter, however this still does not for example tell me what values i can use for `RetentionPolicyType`.
I know `Simple` is one, but still what is the form of Days rather than RP's

Powershell reference should be complete.
nd39475
Enthusiast
Posts: 58
Liked: 7 times
Joined: May 05, 2016 6:28 pm
Full Name: n d
Contact:

Re: powershell reference / lack of detail

Post by nd39475 »

seems to be `UseDeletionGuardDays : True`

but upon my `Set-VBRJobOptions`, neither option shows as changed 🤕.

Dont have time for this mess, will create the jobs with script, then manually edit all 50. 🤦‍♂️🤕
david.domask
Veeam Software
Posts: 1226
Liked: 323 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: powershell reference / lack of detail

Post by david.domask » 1 person likes this post

Hi @nd39475,

Let me save you some clicking and show you how to check the ENum types :)

Code: Select all

PS C:\Users\Administrator> $opts.BackupStorageOptions.RetentionType.GetType().GetEnumValues()
Cycles
Days
What you want for changing from restore points (cycles) to Days is under BackupStorageOptions. You can always call GetType() on most non-boolean properties and then run the GetEnumValues() method to check what options you've got. Most are fairly self-explanatory.

Fetch the job options for the job with Get-VBRJobOptions, edit the returned object accordingly, then pass it to Set-VBRJobOptions as the argument for the -Options parameter
David Domask | Product Management: Principal Analyst
nd39475
Enthusiast
Posts: 58
Liked: 7 times
Joined: May 05, 2016 6:28 pm
Full Name: n d
Contact:

Re: powershell reference / lack of detail

Post by nd39475 »

thank you!

i ended up creating two dummy backupCopy jobs, then getting those option, and applying to each newly created backupCopy job (via script(s) obviously). The only thing that did not populate was the encryption-key. was easier to go set that item per each, then all items per each.

ultimately this, with the above caveat:

Code: Select all

$Testing = $true  #change to $false when ready to write changes

Connect-VBRServer -server veeam-server.domain.tld -port 9392

$TargetVeeamRepo = "VeeamRepoName"
$prefix = "OffSite"
$suffix = "BackupCopy"

$jobs = ( Get-VBRJob | Where-Object {$_.Name -notlike "*Filter1*" -and $_.Name -notlike "*Filter2*"} | Sort-Object -Property Name)

#debugging output
$jobs
$jobs | measure

## use existing job to get $Options
$Options = Get-VBRJob -Name "DUMMY-1-Defaults" | Get-VBRJobOptions

#debugging output
$Options
$Options.GenerationPolicy

foreach ($job in $jobs) {
  $jName = $job.Name
  $NewCopyJobName = $prefix+" "+$jName+" "+$suffix
  Write-Host "`n`n`n******************************************************************************************"
  Write-Host "Job: $jName --> $NewCopyJobName"
  If (!$testing) {
    Write-Host "Adding: BackupCopyJob named `"$NewCopyJobName`" to `"$TargetVeeamRepo`"."
    Add-VBRViBackupCopyJob -DirectOperation -Name "$NewCopyJobName" -BackupJob "$jName" -Repository "$TargetVeeamRepo" -EnableImmediateCopy
    Start-Sleep -Seconds 2 #allow time for next step

    ## set options from "DUMMY-*" job
    Write-Host "Setting options."
    Set-VBRJobOptions -Job "$NewCopyJobName" -Options $Options
    Start-Sleep -Seconds 1
  } else {
    Write-Host "     Testing. Nothing being done."
  }
}

david.domask
Veeam Software
Posts: 1226
Liked: 323 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: powershell reference / lack of detail

Post by david.domask »

Glad to help! And your workaround is a fine idea, I like the strategy of a "donor" job for such settings :)
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests