All Forums Database
bp0308 4 posts Joined 03/14
18 Mar 2014
Calling Power Shell Script from within Bteq script

Hello there,
I hava a Bteq script which does some conditin checking and if the first condition met , it should invoke a powershell script for sending out emails Or exit. I am running on windows.
I am getting error on the line where I am calling the power shell script.
I have something like below:
.if activitycount >0 then EXEC powershell.exe-ExecutionPolicy RemoteSigned- File filepath
I've also tried .OS command, .OS Exec, .OS call, .OS ; none of them are working.
Any help would be greatly appreciated.
Thanks a lot

Raja_KT 1246 posts Joined 07/09
19 Mar 2014

Can you try with both OS and SYSTEM too like:
.SYSTEM 'cmd /c F:\your_directory\...\abc.exe';
Try with just one command , maybe like copy abc file to another directory.
Also try to run the os command independently, without TD script to verify it works. Step-by-step helps :).
Have a look at this link too.

Raja K Thaw
My wiki:
Street Children suffer not by their fault. We can help them if we want.

bp0308 4 posts Joined 03/14
19 Mar 2014

Thanks Raja. Yes I checked the powershell script outside of Bteq and its working fine.
It's still not working when calling from the Bteq script.
I tried the following:
1) .if activitycount >0 then .os command C:\windows\system32\windowspowershell\v1.0\powershell.exe 'E:\folder1\folder2\myscript.ps1'
2) .if activitycount >0 then .os C:\windows\system32\windowspowershell\v1.0\powershell.exe 'E:\folder1\folder2\myscript.ps1'
3) .if activitycount >0 then .os EXEC C:\windows\system32\windowspowershell\v1.0\powershell.exe 'E:\folder1\folder2\myscript.ps1'
4) .if activitycount >0 then .os system C:\windows\system32\windowspowershell\v1.0\powershell.exe 'E:\folder1\folder2\myscript.ps1'
5) .if activitycount >0 then .os C:\windows\system32\windowspowershell\v1.0\powershell.exe
None of the above are working; saying "system call failed".
Have anyone done something similar, like invoking unix shell script from bteq script ?

bp0308 4 posts Joined 03/14
19 Mar 2014

It worked !!
here is what worked for me:
.if activitycount >0 then .os CMD/c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy remotesigned -File E:\your_folder\..\yourscript.ps1
Thanks Raja !

You must sign in to leave a comment.