1-800-691-1991 | 9am - 8pm ET

Running a PowerShell script from a BAT fails when using pre-freeze/post-thaw or pre-job/post job scripts


To provide a bat file template for calling PowerShell scripts to prevent Script execution errors


PowerShell execution policy and UAC/Windows permissions issues may be causing script call to fail


The following template .bat file may be used to call PowerShell scripts.

REM edit the example line bellow to set  PowerShellScriptPath  to the PowerShell script path on the guest VM being backed up
SET PowerShellScriptPath="C:\Windows\Scripts\script.ps1”   
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%PowerShellScriptPath%""' -Verb RunAs}";


More information

When you run a pre-freeze/post-thaw script from a BAT file, the BAT file is stored on the Veeam Backup Server, and will be copied to a temporary location on the guest when the job runs.  The Powershell script will need to be located on the guest that is being backed up and that you want the script to run on.  The path for PowerShellScriptPath variable needs to be the exact path and file name on the guest.    
When you are running pre or post job scripts, both the BAT file and the PowerShell script will be launched from the VeeamBackup server independent of the guest.
For error reporting you can add “>> C:\TEMP\Err_ps.txt” to the end of each action line on the PowerShell script, or “>> C:\TEMP\Err_cmd.txt” to the end of each  action line in the BAT file to get error reporting output. 
Veeam Backup & Replication
Last Modified:
Please rate how helpful this article was to you:
4.5 out of 5 based on 1 ratings
Thank you for helping us improve!
An error occurred during voting. Please try again later.

Couldn't find what you were looking for?

Below you can submit an idea for a new knowledge base article.
Report a typo on this page:

Please select a spelling error or a typo on this page with your mouse and press CTRL + Enter to report this mistake to us. Thank you!

Spelling error in text

Knowledge base content request
By submitting, you agree that your personal data will be managed by Veeam in accordance with the Privacy Policy.

ty icon

Thank you!

We have received your request and our team will reach out to you shortly.


error icon

Oops! Something went wrong.

Please go back try again later.