Comprehensive data protection for all workloads
Post Reply
william88
Enthusiast
Posts: 44
Liked: 13 times
Joined: Feb 27, 2017 7:47 am
Full Name: William
Contact:

SureBackup custom Powershell script error

Post by william88 »

Hi,

Today while testing a custom Powershell script on a VM of an application group I ran into what I think is a bug.

Here's a test script to reproduce the bug:

Code: Select all

param (
    [Parameter(Mandatory = $true)]
    [string]$Text
)

Write-Output "Text value : $Text"
exit 0"
If you call the script this way, everything works fine (simple quoes around the text passed as an argument):

Name : Test-Script1
Path : C:\Test-Script.ps1
Argument : -Text 'Example with space'

If you call the script in this way, it will make an error (double quotes around the text passed as an argument):
Name : Test-Script2
Path : C:\Test-Script.ps1
Argument : -Text "Example with space"

Here's the error :

Code: Select all

[09.07.2025 15:57:52.041]    <61>    Info (3)    [SureBackup] [SRV1] [ScriptTests] Process is starting with the following start info:
[09.07.2025 15:57:52.041]    <61>    Info (3)    [SureBackup] [SRV1] [ScriptTests] > WorkingDirectory = C:\Program Files\Veeam\Backup and Replication\Backup
[09.07.2025 15:57:52.041]    <61>    Info (3)    [SureBackup] [SRV1] [ScriptTests] > FileName = C:\Windows\system32\windowspowershell\v1.0\powershell.exe
[09.07.2025 15:57:52.892]    <53>    Info (3)    [SureBackup] [SRV1] [ScriptTests] [Console] C:\Test-Script.ps1 : Impossible de trouver un paramètre positionnel acceptant l'argument « with ».
[09.07.2025 15:57:52.892]    <53>    Info (3)    [SureBackup] [SRV1] [ScriptTests] [Console] Au caractère Ligne:1 : 1
[09.07.2025 15:57:52.892]    <53>    Info (3)    [SureBackup] [SRV1] [ScriptTests] [Console] + C:\Test-Script.ps1 -Text Example with space
[09.07.2025 15:57:52.892]    <53>    Info (3)    [SureBackup] [SRV1] [ScriptTests] [Console] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[09.07.2025 15:57:52.892]    <53>    Info (3)    [SureBackup] [SRV1] [ScriptTests] [Console]     + CategoryInfo          : InvalidArgument : (:) [Simple-Test.ps1], ParameterBindingException
[09.07.2025 15:57:52.892]    <53>    Info (3)    [SureBackup] [SRV1] [ScriptTests] [Console]     + FullyQualifiedErrorId : PositionalParameterNotFound,Simple-Test.ps1
It seems that the double quotes are removed from command line.
If you call the script directly from the VBR server's Powershell prompt, there's no problem with double quotes around text containing spaces.

Has anyone ever encountered this bug?

Thank you
david.domask
Veeam Software
Posts: 2833
Liked: 647 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: SureBackup custom Powershell script error

Post by david.domask » 1 person likes this post

Hi william88,

Expected behavior here, but it's a bit of a "foot-gun" I agree.

Pre/post-job scripts are passed directly to the VBR server and executed like the following:
[10.07.2025 10:27:01.209] <18> Info (3) Executing custom command [powershell.exe], arguments [ -ExecutionPolicy ByPass -Command " try {& 'C:\scripts\hibye.ps1' -Custom 'blueberry' -ErrorAction Stop } catch { exit 1 } "]
See how the entire command is being wrapped in double-quotes? That's why double-quotes in the arguments don't work because it breaks the quoting for the OS/powershell.

However, I don't see this listed in the User Guide, so I will get that added to the User Guide, as easy to miss
David Domask | Product Management: Principal Analyst
william88
Enthusiast
Posts: 44
Liked: 13 times
Joined: Feb 27, 2017 7:47 am
Full Name: William
Contact:

Re: SureBackup custom Powershell script error

Post by william88 » 1 person likes this post

Hi David,

Thank you for your reply.

This is indeed a good thing if you have the opportunity to update the guide with this information.

Have a nice day
Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Bing [Bot] and 11 guests