-
- Enthusiast
- Posts: 27
- Liked: never
- Joined: Jun 06, 2009 2:46 am
- Full Name: Glen Morris
- Contact:
Running Veeam Powershell script in Backup Job
I would like to run a Veeam powershell script as part of the Advanced Job scripts, I have never did this before what is the best way of running them, [i.e. is there a command to call the Veeam Powershell snap-in]
-
- VP, Product Management
- Posts: 27121
- Liked: 2722 times
- Joined: Mar 30, 2009 9:13 am
- Full Name: Vitaliy Safarov
- Contact:
Re: Running Veeam Powershell script in Backup Job
Yes, there is a command to do that. Please see our on-line User Guide for further details > http://helpcenter.veeam.com/backup/80/powershell/
-
- Product Manager
- Posts: 20284
- Liked: 2258 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Running Veeam Powershell script in Backup Job
In order to get access to VB&R specific commands you'll need to add snap-in to current PS session first.
Thanks.
Code: Select all
Add-PSSnapin VeeamPSSnapin
-
- Enthusiast
- Posts: 27
- Liked: never
- Joined: Jun 06, 2009 2:46 am
- Full Name: Glen Morris
- Contact:
Re: Running Veeam Powershell script in Backup Job
thanks, that works when I run the powershell script.
when I point to the Powershell script file in the Job script [script.ps1] section under Advanced I am recieving an error
The specified executable is not a valid application for this OS platform
It appears to be looking for a .bat .cmd or .exe file
when I point to the Powershell script file in the Job script [script.ps1] section under Advanced I am recieving an error
The specified executable is not a valid application for this OS platform
It appears to be looking for a .bat .cmd or .exe file
-
- Product Manager
- Posts: 20284
- Liked: 2258 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Running Veeam Powershell script in Backup Job
Yep, both pre and post job commands should be batch. But there is nothing preventing you from triggering PS scripts from a batch. Thanks.
-
- Veeam Software
- Posts: 643
- Liked: 162 times
- Joined: Dec 10, 2012 8:44 am
- Full Name: Nikita Efes
- Contact:
Re: Running Veeam Powershell script in Backup Job
You could also use such string:
Code: Select all
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe <path to your file>.ps1
-
- Enthusiast
- Posts: 27
- Liked: never
- Joined: Jun 06, 2009 2:46 am
- Full Name: Glen Morris
- Contact:
Re: Running Veeam Powershell script in Backup Job
Thanks, I created the following batch file in the same folder [same name] as the PS script. it works good.
@ECHO OFF
powershell.exe -noninteractive -noprofile -Command "& '%~dpn0.ps1'"
EXIT /B %errorlevel%
@ECHO OFF
powershell.exe -noninteractive -noprofile -Command "& '%~dpn0.ps1'"
EXIT /B %errorlevel%
-
- Novice
- Posts: 3
- Liked: never
- Joined: Feb 08, 2014 2:08 pm
- Full Name: Gary Holder
- Contact:
Re: Running Veeam Powershell script in Backup Job
-command didnt work for me...this did
@echo off
Powershell.exe set-executionpolicy remotesigned -File C:\Users\SE\Desktop\ps.ps1
@echo off
Powershell.exe set-executionpolicy remotesigned -File C:\Users\SE\Desktop\ps.ps1
-
- Enthusiast
- Posts: 28
- Liked: 3 times
- Joined: Jan 14, 2015 7:01 am
- Contact:
Re: Running Veeam Powershell script in Backup Job
I think that powershell should be supported directly.
I don't get why it isn't. Most of Veeam is in fact PS-Scriptable.
Only for the pre/post-scripts you have to do those stupid workarounds that then cause your number of scripts to maintain to double
Please add this![Wink ;)](https://forums.veeam.com/images/smilies/icon_wink.gif)
Best regards
I don't get why it isn't. Most of Veeam is in fact PS-Scriptable.
Only for the pre/post-scripts you have to do those stupid workarounds that then cause your number of scripts to maintain to double
Please add this
![Wink ;)](https://forums.veeam.com/images/smilies/icon_wink.gif)
Best regards
-
- Influencer
- Posts: 18
- Liked: never
- Joined: Aug 23, 2013 2:25 pm
- Full Name: Erhardt
- Contact:
Re: Running Veeam Powershell script in Backup Job
gholder wrote:-command didnt work for me...this did
@echo off
Powershell.exe set-executionpolicy remotesigned -File C:\Users\SE\Desktop\ps.ps1
Had to use
Code: Select all
@ECHO OFF
Powershell.exe -ExecutionPolicy ByPass -File C:\Powershell-Script\1337script.ps1
EXIT
Yes, fully agree with youchas0rde wrote:I think that powershell should be supported directly.
I don't get why it isn't. Most of Veeam is in fact PS-Scriptable
![Exclamation :!:](https://forums.veeam.com/images/smilies/icon_exclaim.gif)
-
- Service Provider
- Posts: 452
- Liked: 30 times
- Joined: Dec 28, 2014 11:48 am
- Location: The Netherlands
- Contact:
Re: Running Veeam Powershell script in Backup Job
For windows 2012 R2 is use the following oneliners on the Veeam Backup Server:
works as a charm ![Smile :)](https://forums.veeam.com/images/smilies/icon_smile.gif)
Code: Select all
c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe c:\scripts\prescript.ps1
c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe c:\scripts\postscript.ps1
![Smile :)](https://forums.veeam.com/images/smilies/icon_smile.gif)
-
- Enthusiast
- Posts: 28
- Liked: 3 times
- Joined: Jan 14, 2015 7:01 am
- Contact:
Re: Running Veeam Powershell script in Backup Job
Do you add this oneliner as command for pre-/post-script in the Veeam config or just in a batch?lowlander wrote:For windows 2012 R2 is use the following oneliners on the Veeam Backup Server:works as a charmCode: Select all
c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe c:\scripts\prescript.ps1 c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe c:\scripts\postscript.ps1
-
- Product Manager
- Posts: 20284
- Liked: 2258 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Running Veeam Powershell script in Backup Job
Pre/Post job activity would be my guess, as the provided examples should work fine for them. Though, avoid using them as a pre-freeze/post-thaw scripts, since those work differently. Thanks.
-
- Enthusiast
- Posts: 28
- Liked: 3 times
- Joined: Jan 14, 2015 7:01 am
- Contact:
Re: Running Veeam Powershell script in Backup Job
Yes. Pre-Freeze/Post-Thaw would only copy the batch and not find the ps1v.Eremin wrote:Though, avoid using them as a pre-freeze/post-thaw scripts, since those work differently
I use network stored ps1's for that purpose and reference to the UNC path. Works and allows easier maintenance of the scripts (single location and no more copy stuff back and forth)
Who is online
Users browsing this forum: No registered users and 26 guests