Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Knowledge Base

Definitive answers from Designer Desktop 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
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
10 - Fireball

@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