PowerShell script exchange
Post Reply
chris.childerhose
Veeam Vanguard
Posts: 636
Liked: 154 times
Joined: Aug 13, 2014 6:03 pm
Full Name: Chris Childerhose
Location: Toronto, ON
Contact:

Enable Bitlooker - Powershell

Post by chris.childerhose »

I am trying to run this script on one of my VBR servers (9.5 Update 4a) but it fails to set the option. So my question is what is the option for setting this? Is there a guide to the options for jobs and the corresponding Powershell option somewhere?

Script -

asnp VeeamPSSNapin
foreach ($Job in Get-VBRJob | where {$_.JobType -eq "Backup" -or $_.JobType -eq "Replica"})
{
$Options = $Job.GetOptions()
$Options.ViSourceOptions.DirtyBlocksNullingEnabled = $True
$Job.SetOptions($Options)
}
-----------------------
Chris Childerhose
Veeam Vanguard / Veeam Legend / Veeam Ceritified Architect / VMCE
vExpert / VCAP-DCA / VCP8 / MCITP
Personal blog: https://just-virtualization.tech
Twitter: @cchilderhose
jhoughes
Veeam Vanguard
Posts: 282
Liked: 113 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Enable Bitlooker - Powershell

Post by jhoughes »

I just verified that this worked successfully in my lab against 9.5U4a:

Code: Select all

$job = Get-VBRJob -Name 'AUSVCENTER-NoTag'
$joboptions = Get-VBRJobOptions -Job $job
$joboptions.ViSourceOptions.ExcludeSwapFile = $true
$joboptions.ViSourceOptions.DirtyBlocksNullingEnabled = $true
Set-VBRJobOptions -Job $job -Options $joboptions
Job options prior to running code:

Code: Select all

(Elevated) jhoughes@AUSDEV01 : D:\Code : 6/26/2019 08:57:28 :
> $job = Get-VBRJob -Name 'AUSVCENTER-NoTag'

(Elevated) jhoughes@AUSDEV01 : D:\Code : 6/26/2019 08:57:48 :
> $job.Options.ViSourceOptions

EncryptLanTraffic         : False
FailoverToNetworkMode     : False
VCBMode                   : san
VDDKMode                  : san;nbd
UseChangeTracking         : True
EnableChangeTracking      : True
VMToolsQuiesce            : True
VmAttributeName           : Veeam_Backup_Time
BackupTemplates           : True
ExcludeSwapFile           : False
DirtyBlocksNullingEnabled : False
BackupTemplatesOnce       : True
SetResultsToVmNotes       : True
VmNotesAppend             : True

Job options after running code:

Code: Select all

(Elevated) jhoughes@AUSDEV01 : D:\Code : 6/26/2019 08:59:05 :
> $job = Get-VBRJob -Name 'AUSVCENTER-NoTag'

(Elevated) jhoughes@AUSDEV01 : D:\Code : 6/26/2019 08:59:11 :
> $job.Options.ViSourceOptions

EncryptLanTraffic         : False
FailoverToNetworkMode     : False
VCBMode                   : san
VDDKMode                  : san;nbd
UseChangeTracking         : True
EnableChangeTracking      : True
VMToolsQuiesce            : True
VmAttributeName           : Veeam_Backup_Time
BackupTemplates           : True
ExcludeSwapFile           : True
DirtyBlocksNullingEnabled : True
BackupTemplatesOnce       : True
SetResultsToVmNotes       : True
VmNotesAppend             : True

Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
chris.childerhose
Veeam Vanguard
Posts: 636
Liked: 154 times
Joined: Aug 13, 2014 6:03 pm
Full Name: Chris Childerhose
Location: Toronto, ON
Contact:

Re: Enable Bitlooker - Powershell

Post by chris.childerhose »

I tried your script and got the following so something is off in my environment -

Code: Select all

The property 'DirtyBlocksNullingEnabled' cannot be found on this object. Verify that the property exists and can be
set.
At C:\Users\blackbird\Documents\Dirty_Blocks_Enable_3.ps1:4 char:1
+ $joboptions.ViSourceOptions.DirtyBlocksNullingEnabled = $true
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

Set-VBRJobOptions : Cannot convert 'System.Object[]' to the type 'Veeam.Backup.Model.CJobOptions' required by
parameter 'Options'. Specified method is not supported.
At C:\Users\blackbird\Documents\Dirty_Blocks_Enable_3.ps1:5 char:38
+ Set-VBRJobOptions -Job $job -Options $joboptions
+                                      ~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Set-VBRJobOptions], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Veeam.Backup.PowerShell.Cmdlets.SetVBRJobOptions
-----------------------
Chris Childerhose
Veeam Vanguard / Veeam Legend / Veeam Ceritified Architect / VMCE
vExpert / VCAP-DCA / VCP8 / MCITP
Personal blog: https://just-virtualization.tech
Twitter: @cchilderhose
chris.childerhose
Veeam Vanguard
Posts: 636
Liked: 154 times
Joined: Aug 13, 2014 6:03 pm
Full Name: Chris Childerhose
Location: Toronto, ON
Contact:

Re: Enable Bitlooker - Powershell

Post by chris.childerhose »

Seems to work ok if I specify a job but not when using wildcard (*) for all jobs.
-----------------------
Chris Childerhose
Veeam Vanguard / Veeam Legend / Veeam Ceritified Architect / VMCE
vExpert / VCAP-DCA / VCP8 / MCITP
Personal blog: https://just-virtualization.tech
Twitter: @cchilderhose
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Enable Bitlooker - Powershell

Post by veremin »

Some object of different type seems to get assigned to $Job or $JobOptions variable, try to limit the script to backup job first and see whether it works:

Code: Select all

foreach ($Job in Get-VBRJob | where {$_.JobType -eq "Backup"})
{
$joboptions = Get-VBRJobOptions -Job $job
$joboptions.ViSourceOptions.ExcludeSwapFile = $true
$joboptions.ViSourceOptions.DirtyBlocksNullingEnabled = $true
Set-VBRJobOptions -Job $job -Options $joboptions
}
Thanks!
chris.childerhose
Veeam Vanguard
Posts: 636
Liked: 154 times
Joined: Aug 13, 2014 6:03 pm
Full Name: Chris Childerhose
Location: Toronto, ON
Contact:

Re: Enable Bitlooker - Powershell

Post by chris.childerhose »

That fixed the issue for me. Thanks. 8)
-----------------------
Chris Childerhose
Veeam Vanguard / Veeam Legend / Veeam Ceritified Architect / VMCE
vExpert / VCAP-DCA / VCP8 / MCITP
Personal blog: https://just-virtualization.tech
Twitter: @cchilderhose
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Enable Bitlooker - Powershell

Post by veremin »

Most likely, some file or copy jobs got assigned to the $Job variable previously, those object didn't have the said property, as the result the script failed.

Glad to hear that you've fixed the issue.

Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests