Jump to content
Ketarin forum

TIP: Calling Powershell scripts(*.ps1) from Ketarin


Ambimind
 Share

Recommended Posts

Motivation 

PSlang is overloaded, confounding and extremely verbose, however its well integrated .net: regex, http and file processing facilities - make it worthwhile in complex tasks. Such a complex task may involve sending post data with dynamically generated cookies and varying referrer-urls, across several http requests. 

 

Example   

A PS script file (FabsAB.ps1) is placed in the directory intended for a downloadable installer. The script is written so as to download and process files within its containing folder. It is assumed that Ketarin is aware of this folder via its "Download location"(Application tab) setting.

 

Solution   

included below is the command  to call this script, and its placement with other commands, part of the pre-download steps for the job :

 

POWERSHELL -command ".\FabsAB.ps1"

 

aotq81A.png

 

Problems 

If after running the command one finds Ketarin unable to finish it, it will be necessary to find "Powershell.exe" in "Windows Task Manager" and kill the process.

This is likely related to PS security restrictions. To resolve this we need to set "PS execution policy" for both the "LocalMachine" and "CurrentUser":

 

Within a PS terminal with admin-rights type one after the other:

 

Set-ExecutionPolicy Unrestricted -Scope CurrentUser

then type "Y"

 

Set-ExecutionPolicy Unrestricted -Scope LocalMachine

then type "Y"

 

Get-ExecutionPolicy -List

to check the current state of affairs

 

Remarks

It is also possible to run multiple Powershell commands, not written in a file :

POWERSHELL -command "Get-Content a.txt -Raw; $fab='All done'; $fab" 

 

Link to comment
Share on other sites

  • 4 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.