PowerShell script exchange
Post Reply
karim
Enthusiast
Posts: 51
Liked: 5 times
Joined: Oct 17, 2018 9:01 am
Contact:

set pre-freeze and post-thaw scripts for a vm

Post by karim »

hi,
i'm unable to find how to set pre-freeze and post-thaw scripts with powershell.
i tried this :

Code: Select all

$object = Get-VBRJob -Name "b_infras_3h" | Get-VBRJobObject -Name "DELLSTORMAN"
$vssobjoptions.VssSnapshotOptions.Enabled = $True
$vssobjoptions = Get-VBRJob -Name "b_infras_3h" |Get-VBRJobObject -Name "DELLSTORMAN" | Get-VBRJobObjectVssOptions
$vssobjoptions.GuestScriptsOptions.ScriptingMode = "FailJobOnError"
$vssobjoptions.GuestScriptsOptions.WinScriptFiles.PreScriptFilePath = "L:\Scripts\Windows\Backup_mssql.cmd"
$vssobjoptions.GuestScriptsOptions.WinScriptFiles.PostScriptFilePath = "L:\Scripts\Windows\Backup_databases.cmd"
Set-VBRJobObjectVssOptions -Options $vssobjoptions -Object $object
but after apply, i only find the script processing mode set to "Require successful script execution" but not script are set.

what i'm doing wrong?

thank you.
Vek17
Service Provider
Posts: 49
Liked: 15 times
Joined: May 29, 2018 8:42 pm
Contact:

Re: set pre-freeze and post-thaw scripts for a vm

Post by Vek17 » 2 people like this post

You are going to have to set it via a new WinScriptFiles object

Code: Select all

$object = Get-VBRJob -Name "b_infras_3h" | Get-VBRJobObject -Name "DELLSTORMAN"
$vssobjoptions.VssSnapshotOptions.Enabled = $True
$vssobjoptions = Get-VBRJob -Name "b_infras_3h" |Get-VBRJobObject -Name "DELLSTORMAN" | Get-VBRJobObjectVssOptions
$vssobjoptions.GuestScriptsOptions.ScriptingMode = "FailJobOnError"
$vssobjoptions.GuestScriptsOptions.WinScriptFiles = [Veeam.Backup.Model.CScriptFiles]::new( "L:\Scripts\Windows\Backup_mssql.cmd", "L:\Scripts\Windows\Backup_databases.cmd")
Set-VBRJobObjectVssOptions -Options $vssobjoptions -Object $object
karim
Enthusiast
Posts: 51
Liked: 5 times
Joined: Oct 17, 2018 9:01 am
Contact:

Re: set pre-freeze and post-thaw scripts for a vm

Post by karim »

hello
it works :) thank you!
dbr
Expert
Posts: 118
Liked: 14 times
Joined: Apr 06, 2017 9:48 am
Full Name: Daniel Brase
Contact:

Re: set pre-freeze and post-thaw scripts for a vm

Post by dbr »

Hi all,

I had the same problem when settings guestprocessing scripts via powershell. Unfortunately, it seems that the method "new" isn't availble to the WinScriptFiles object anymore. I'm running 9.5 U4 and was able to get that working with something like this:

Code: Select all

$scriptsobject=[Veeam.Backup.Model.CScriptFiles]::CreateDefault()
$scriptsobject.PreScriptFilePath="C:\Scripts\guestprocessing\db2\pre-freeze.cmd"
$scriptsobject.PostScriptFilePath="C:\Scripts\guestprocessing\db2\post-thaw.cmd"
$jobobjectvssoptions = Get-VBRJobObjectVssOptions -objectinjob <jobobject>
$jobobjectvssoptions.guestscriptsoptions.ScriptingMode="FailJobOnError"
$jobobjectvssoptions.guestscriptsoptions.winscriptfiles=$scriptsobject
Set-VBRJobObjectVssOptions -object $jobobject -options $jobobjectvssoptions
Daniel
Vek17
Service Provider
Posts: 49
Liked: 15 times
Joined: May 29, 2018 8:42 pm
Contact:

Re: set pre-freeze and post-thaw scripts for a vm

Post by Vek17 »

Glad that you got it working, but as far as I can tell you can still build a new [Veeam.Backup.Model.CScriptFiles] the same way as U3 (And I still am using it currently).
Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests