Quantcast
Channel: R&D Forums
Viewing all articles
Browse latest Browse all 9965

PowerShell • Add pre-freeze/post-thaw script for Win PG in Appaware settings

$
0
0
Hi there,

I'm struggling with adding Pre/Post freeze scripts to a Windows Agent Protection Group in app aware settings of a Windows Agent Job.
All ideas Veeam AI delivers to me are not functional.

Code:

# Define the name of the backup job and the pre-freeze script path$jobName = "Windows Agent Backup Job"$preFreezeScriptPath = "C:\Scripts\PreFreezeScript.ps1"# Get the backup job$job = Get-VBRComputerBackupJob -Name $jobName# Get the protection group$protectionGroup = Get-VBRProtectionGroup -Name "Windows Servers"# Get the application aware settings$appAwareSettings = $protectionGroup.Options.ApplicationAwareProcessing# Define the pre-freeze script$appAwareSettings.PreFreezeScript = $preFreezeScriptPath# Apply the updated settings to the protection groupSet-VBRProtectionGroupOptions -ProtectionGroup $protectionGroup -Options $protectionGroup.OptionsWrite-Output "Pre-Freeze Script has been defined for the protection group: Windows Servers"
In this example:
$protectionGroup.Options.ApplicationAwareProcessing is not a valid sub property

I got lot of these, where either invalid sub properties are used, or incompatible cmdlets where chained.


My latest personal approach was this here

Code:

# Setting Pre/Post Scripts in Backup Job$paramNewVBRScriptProcessingOptions = @{ScriptPrefreezeCommand = "D:\VeeamScripts\preFreeze.bat"ScriptPostthawCommand  = "D:\VeeamScripts\postFreeze.bat"ProcessingAction   = 'IgnoreFailures'}$ErrorObject | Add-Member -Force -NotePropertyName paramNewVBRScriptProcessingOptions -NotePropertyValue $paramNewVBRScriptProcessingOptions$scriptOptions = New-VBRScriptProcessingOptions @paramNewVBRScriptProcessingOptions#$JobOptions = Set-VBRApplicationProcessingOptions -ScriptProcessingOptions $scriptOptions#$pgInJob = Get-VBRJobObject -Job $job #| Where-Object { $_.Name -eq $ProtectionGroupParams['Name'] }$pgInJob = Get-VBRProtectionGroup -Name $ProtectionGroupParams['Name'] $ProcessOptions = New-VBRApplicationProcessingOptions -BackupObject $pgInJob -Enable -ScriptProcessingOptions $scriptOptions -OSPlatform Windows -GeneralTransactionLogAction ProcessLogsWithJob$null = Set-VBRApplicationProcessingOptions -Options $ProcessOptions -Enable -GeneralTransactionLogAction ProcessLogsWithJob$AllRes += Write-CSDLog -LogText "$($MyInvocation.MyCommand)~Created Pre/Post Script object" -Severity I -Object $TemplateJob$null = Enable-VBRComputerBackupJob -Job $job$AllRes += Write-CSDLog -LogText "$($MyInvocation.MyCommand)~Job enabled" -Severity I -Object $TemplateJob
This one doesn't thow any errors. But my desired settings are also not set.
Any ideas what I'm doing wrong?

Statistics: Posted by manuel.aigner — Jun 27, 2025 1:24 pm



Viewing all articles
Browse latest Browse all 9965

Latest Images

Trending Articles



Latest Images