PowerShell script exchange
vmm
Service Provider
Posts: 15 Liked: never
Joined: Nov 23, 2015 10:09 am
Full Name: Marat Akhmetianov
Contact:
Post
by vmm » Nov 27, 2015 10:05 am
this post
Code: Select all
$vps = Find-VBRViEntity -Name "vps-8"
$repository = Get-VBRBackupRepository -Name "Backup Repository 1"
Add-VBRViBackupJob -Name "DM_TEST" -Entity $vps -BackupRepository $repository
Get-VBRJob -Name "DM_TEST" | Set-VBRJobAdvancedBackupOptions -Algorithm ReverseIncremental
Get-VBRJob -Name "DM_TEST" | Set-VBRJobAdvancedOptions -RetainDays 14
Get-VBRJob -Name "DM_TEST" | Set-VBRJobAdvancedViOptions -VMToolsQuiesce $True
$Job = Get-VBRJob -Name "DM_TEST"
$Options = $Job.GetOptions()
$Options.SanIntegrationOptions.FailoverFromSan = $True
$Options.BackupStorageOptions.StgBlockSize = "KbBlockSize512"
$Options.BackupStorageOptions.RetainCycles = 1
$Job.SetOptions($Options)
After issuing this script I can change VM retention policy (number of days) but can not enable it
veremin
Product Manager
Posts: 20400 Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:
Post
by veremin » Nov 27, 2015 10:41 am
this post
What do you mean by enable? The retention policy is enabled by default, and cannot be disabled. Or you're talking about
deleted VM retention ?
vmm
Service Provider
Posts: 15 Liked: never
Joined: Nov 23, 2015 10:09 am
Full Name: Marat Akhmetianov
Contact:
Post
by vmm » Nov 27, 2015 10:51 am
this post
Yes for deleted VM retention.
veremin
Product Manager
Posts: 20400 Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:
Post
by veremin » Nov 27, 2015 11:05 am
this post
Then, try the following script:
Code: Select all
$Job = Get-VBRJob -Name "Job Name"
$Options = $Job.GetOptions()
$Job.BackupStorageOptions.EnableDeletedVmDataRetention = $true
$Options.BackupStorageOptions.RetainDays = "Desired value"
$Job.SetOptions($Options)
Thanks.
vmm
Service Provider
Posts: 15 Liked: never
Joined: Nov 23, 2015 10:09 am
Full Name: Marat Akhmetianov
Contact:
Post
by vmm » Nov 27, 2015 11:16 am
this post
Great. Thanks. Everything worked
veremin
Product Manager
Posts: 20400 Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:
Post
by veremin » Nov 27, 2015 11:28 am
this post
You're welcome. Should other help be needed, don't hesitate to let us know. Thanks.
evilaedmin
Expert
Posts: 176 Liked: 30 times
Joined: Jul 26, 2018 8:04 pm
Full Name: Eugene V
Contact:
Post
by evilaedmin » Dec 25, 2018 4:50 am
this post
I think I found it:
Code: Select all
$JobOptions.BackupStorageOptions.RetainDays
$JobOptions.BackupStorageOptions.EnableDeletedVmDataRetention
Is there a reference for mapping the graphic interface elements to Powershell? I don't believe these are obvious at all at first glance!
veremin
Product Manager
Posts: 20400 Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:
Post
by veremin » Dec 25, 2018 9:38 am
1 person likes this post
Yep, you've found the proper way to modify those settings. Don't forget to apply new values via .SetOptions method. Thanks!
evilaedmin
Expert
Posts: 176 Liked: 30 times
Joined: Jul 26, 2018 8:04 pm
Full Name: Eugene V
Contact:
Post
by evilaedmin » Dec 26, 2018 1:59 am
this post
Don't forget to apply new values via .SetOptions method.
I used the pattern in the
example 1 :
Code: Select all
$JobOptions = Get-VBRJobOptions -Job $job
$JobOptions.BackupStorageOptions.RetainDays = 90
$JobOptions.BackupStorageOptions.EnableDeletedVmDataRetention = $True
Set-VBRJobOptions -Job $job -Options $JobOptions
Is that what you mean?
veremin
Product Manager
Posts: 20400 Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:
Post
by veremin » Dec 26, 2018 11:48 am
1 person likes this post
Correct, new settings can be applied either via cmdlet Set-VBRJobOptions or job dynamic method .SetOptions() (for instance, $Job.SetOptions($JobOptions)). Thanks!
Users browsing this forum: No registered users and 12 guests