08-24-2016 02:14 PM - edited 08-03-2021 01:06 PM
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:
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:
I have noticed powershell is not working anymore after upgrading to 11.7. Can you confirm?
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
@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"'
@Ozzie Would you happen to know how to use the Run Command to run a powershell script that is constructed using formula tool?
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?
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.
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'"