PowerShell script exchange
mongie
Expert
Posts: 152 Liked: 24 times
Joined: May 16, 2011 4:00 am
Full Name: Alex Macaronis
Location: Brisbane, Australia
Contact:
Post
by mongie » Oct 03, 2016 9:52 pm
this post
I'm trying to schedule a tape library inventory to run prior to my weekly tape backup. I've done this via the pre-job script funcitonality.
Problem is, while I know how to make powershell wait for the inventory before closing, I don't know how to get the batch file to respect that powershell is still running...
Powershell is...
Code: Select all
Add-PSSnapin -Name VeeamPSSnapin
Get-VBRTapeLibrary | Start-VBRTapeInventory -Wait
Batch File is...
Code: Select all
@ECHO OFF
Powershell.exe -ExecutionPolicy ByPass -File "C:\Program Files (x86)\Veeam\runVBRInventory.ps1"
EXIT
Any suggestions on...
a) how to run a powershell file as the pre job script?
b) how to get the batch file to run until the inventory has finished?
Thanks
tsightler
VP, Product Management
Posts: 6035 Liked: 2860 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:
Post
by tsightler » Oct 04, 2016 12:20 am
this post
You can run a Powershell script directly (without a batch file) using syntax similar to this in the pre/post-script settings:
Code: Select all
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noninteractive -file "C:\Program Files (x86)\Veeam\runVBRInventory.ps1"
I guess I haven't tried it with spaces + quotes, but I'd think it would work just fine, but I usually just stick my scripts in C:\Scripts to keep the path short and provide a standard location.
Worst case you should be able to edit the batch to use start like:
Code: Select all
@ECHO OFF
start /wait Powershell.exe -ExecutionPolicy ByPass -File "C:\Program Files (x86)\Veeam\runVBRInventory.ps1"
EXIT
mongie
Expert
Posts: 152 Liked: 24 times
Joined: May 16, 2011 4:00 am
Full Name: Alex Macaronis
Location: Brisbane, Australia
Contact:
Post
by mongie » Oct 09, 2016 9:30 pm
this post
Thanks for the suggestion, unfortunately both methods still don't work. I also changed the path of the scripts as you suggested with no luck.
veremin
Product Manager
Posts: 20413 Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:
Post
by veremin » Oct 10, 2016 9:15 am
this post
Can you elaborate on what exactly didn't work as expected? The script didn't get executed? Did it fail with some message? Did work incorrectly? Or something else? Thanks.
mongie
Expert
Posts: 152 Liked: 24 times
Joined: May 16, 2011 4:00 am
Full Name: Alex Macaronis
Location: Brisbane, Australia
Contact:
Post
by mongie » Oct 11, 2016 2:25 am
this post
1. Tape backup starts,
2. Pre-job script is marked as successful (almost immediately)
3. Inventory doesn't start (even though it does when I run the script manually).
4. Tape job continues without inventory having run.
What I want to happen is...
1. Tape Job starts
2. Pre-job script starts - tape job waits for the task to complete
3. Inventory job starts (triggered by pre-job script).
4. Inventory completes and tape job continues.
mongie
Expert
Posts: 152 Liked: 24 times
Joined: May 16, 2011 4:00 am
Full Name: Alex Macaronis
Location: Brisbane, Australia
Contact:
Post
by mongie » Oct 11, 2016 2:27 am
this post
There are two obvious feature requests here too...
a) Ability to schedule an inventory job
b) Ability to automatically run an inventory before a tape job - via gui options.
veremin
Product Manager
Posts: 20413 Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:
Post
by veremin » Oct 11, 2016 11:48 am
this post
2. Pre-job script is marked as successful (almost immediately) 3. Inventory doesn't start (even though it does when I run the script manually).
Most likely, backup service account doesn't have sufficient permissions. Thus, the script got started, did nothing and ended.
As to the feature request, those should be better submitted on tapes subforum to draw sufficient attention.
Thanks.
mongie
Expert
Posts: 152 Liked: 24 times
Joined: May 16, 2011 4:00 am
Full Name: Alex Macaronis
Location: Brisbane, Australia
Contact:
Post
by mongie » Oct 12, 2016 2:13 am
this post
Where is the service account defined?
tdewin
Veeam Software
Posts: 1818 Liked: 655 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:
Post
by tdewin » Oct 12, 2016 6:52 am
this post
Add this to the end of the script to see what errors come up.
Provided that c:\logs directory exists
veremin
Product Manager
Posts: 20413 Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:
Post
by veremin » Oct 12, 2016 8:48 am
this post
Where is the service account defined?
Account under which backup service is running. Thanks.
Users browsing this forum: No registered users and 12 guests