Inspire EMEA 2022 On-Demand is live! Watch now, and be sure to save the date for Inspire 2023 in Las Vegas next May.
We'll be completing standard maintenance for our Single Sign-On system on November 30th 6pm Pacific Time for approximately one hour. During this time My Alteryx and sign-in functionality to all My Alteryx programs (Licensing Portal, Community, Beta Program, Case Portal, and others) may be inaccessible. Thank you for your patience.

Alteryx Designer Knowledge Base

Definitive answers from Designer experts.

How To: Use PowerShell with Alteryx

Ozzie
Alteryx
Alteryx
Created

Alteryx can use theRun Command Toolto runPowershell scripts and perform any Powershell specific commands. Note that in order to run PowerShell scripts you must make sure you have scripting enabled. You should consult with your IT department to see if you are allowed to enablethis functionality.

Below is an example I made demonstrating the necessary run command tool configuration. The command will justbe “PowerShell” toenable PowerShell mode in cmd.exe. Then your command arguments shouldbe the path where the script is located so it can run:

2019-04-22_10-44-39.png

In this particular case, I want to read into the Designer the results of my script, so I specify thefile that is being writtenas the Read Results. My “helloworld.ps1” script only contains the below:

"Hello World" | Out-File c:\temp\test1.txt

As you can see, this kicks off in the Designer and opens the script output file to continue downstream, successfully implementing Powershell scripting:

powershellbrowse.jpg

Attachments
No ratings
Comments
Inactive User
Not applicable

I have noticed powershell is not working anymore after upgrading to 11.7. Can you confirm?

jdrummey
9 - Comet

Hi, this was helpful, thanks!

 

One note - I had a script located in a folder with spaces in the name like C:\foo bar\baz.ps1 and had to use single quotes instead of double quotes in the Command Arguments, e.g. & 'C:\foo bar\baz.ps1' worked while  & "C:\foo bar\baz.ps1" errored out with error code 1.

 

Jonathan

 

BretCarr
9 - Comet

@jdrummey : did you ever figure this out? I was having the same issue and I believe that it is just where your quotes are.

 

Run External program:

powershell

 

Command Arguments [Optional]:

'& "C:\foo bar\baz.ps1"'
avanibhatnagar
8 - Asteroid

@Ozzie Would you happen to know how to use the Run Command to run a powershell script that is constructed using formula tool? 

avanibhatnagar_1-1629732912965.png

 

My formula tool is constructing a powershell script to zip all pdfs created by the workflow in the steps before this and output to a destination. How would I call the results from the Formula tool into the Run Command tool to process that powershell and then output that zip file?

 

 

 

 

byagelski
8 - Asteroid

Was there ever a solution on how to construct a powershell query to be run via the Run Command tool.  I have a use case that needs exactly this.

 

gkumar
5 - Atom

I realize this is a very old thread but posting the full and working solution for passing a powershell script file for path with spaces in them as I was struggling a lot with the other posted examples and through trial and error (and powershell examples running from the command line, found the combination that works always.

 

Here is the example

Command: powershell

Command Arguments: & 'D:\Alteryx Samples\Powershell Scripts\helloworld.ps1'

 

Another variation of the command arguments

-Command "& 'D:\Production Support\Unused Custom Calcs and Returns\helloworld.ps1'"

 

AlteryxGui_2022-11-10_16-53-42.jpg