PowerShell script exchange
Post Reply
chris.childerhose
Service Provider
Posts: 104
Liked: 12 times
Joined: Aug 13, 2014 6:03 pm
Full Name: Chris Childerhose
Location: Toronto, ON
Contact:

Enable Bitlooker - Powershell

Post by chris.childerhose » Jun 26, 2019 1:54 pm

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 / VMCE v9
VCAP-DCA / VCP6 / MCITP
Personal blog: https://just-virtualization.tech
Twitter: @cchilderhose

jhoughes
Veeam Software
Posts: 84
Liked: 16 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Austin, TX
Contact:

Re: Enable Bitlooker - Powershell

Post by jhoughes » Jun 26, 2019 2:05 pm

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 Extraordinaire | @AustinVMUG & @ATXPowerShell leader | vExpert | Cisco Champion | Tech Field Day Delegate | VCP 4/5/6 | VCP6-NV | VMware/Cisco UCS/Powershell/VEEAM Enthusiast

chris.childerhose
Service Provider
Posts: 104
Liked: 12 times
Joined: Aug 13, 2014 6:03 pm
Full Name: Chris Childerhose
Location: Toronto, ON
Contact:

Re: Enable Bitlooker - Powershell

Post by chris.childerhose » Jun 26, 2019 2:17 pm

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 / VMCE v9
VCAP-DCA / VCP6 / MCITP
Personal blog: https://just-virtualization.tech
Twitter: @cchilderhose

chris.childerhose
Service Provider
Posts: 104
Liked: 12 times
Joined: Aug 13, 2014 6:03 pm
Full Name: Chris Childerhose
Location: Toronto, ON
Contact:

Re: Enable Bitlooker - Powershell

Post by chris.childerhose » Jun 26, 2019 2:32 pm

Seems to work ok if I specify a job but not when using wildcard (*) for all jobs.
-----------------------
Chris Childerhose
Veeam Vanguard / VMCE v9
VCAP-DCA / VCP6 / MCITP
Personal blog: https://just-virtualization.tech
Twitter: @cchilderhose

veremin
Product Manager
Posts: 16497
Liked: 1371 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Enable Bitlooker - Powershell

Post by veremin » Jun 26, 2019 3:20 pm

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
Service Provider
Posts: 104
Liked: 12 times
Joined: Aug 13, 2014 6:03 pm
Full Name: Chris Childerhose
Location: Toronto, ON
Contact:

Re: Enable Bitlooker - Powershell

Post by chris.childerhose » Jun 26, 2019 3:29 pm

That fixed the issue for me. Thanks. 8)
-----------------------
Chris Childerhose
Veeam Vanguard / VMCE v9
VCAP-DCA / VCP6 / MCITP
Personal blog: https://just-virtualization.tech
Twitter: @cchilderhose

veremin
Product Manager
Posts: 16497
Liked: 1371 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Enable Bitlooker - Powershell

Post by veremin » Jun 26, 2019 3:42 pm

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 5 guests