PowerShell script exchange
Post Reply
karim
Influencer
Posts: 16
Liked: never
Joined: Oct 17, 2018 9:01 am
Contact:

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

Post by karim » Oct 30, 2018 2:12 pm

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: 36
Liked: 9 times
Joined: May 29, 2018 8:42 pm
Contact:

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

Post by Vek17 » Oct 31, 2018 1:29 pm 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
Influencer
Posts: 16
Liked: never
Joined: Oct 17, 2018 9:01 am
Contact:

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

Post by karim » Nov 15, 2018 9:29 am

hello
it works :) thank you!

dbr
Enthusiast
Posts: 62
Liked: 3 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 » May 20, 2019 2:09 pm

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: 36
Liked: 9 times
Joined: May 29, 2018 8:42 pm
Contact:

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

Post by Vek17 » May 20, 2019 7:28 pm

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: amccloud and 5 guests