Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Run Command Tool configuration for PowerShell Script

IlliasB22
6 - Meteoroid

Hi, 

 

I have a PowerShell script that takes a weekly excel report and updates a table. I am trying to automate this in Alteryx so that I can push this data into a database but am stuck at the configuration of the RunCommand tool 

 

So far I have set the Output to the database and the Command as the file where the PowerShell script is stored however, I am unsure if that is the correct thing to do. I understand that the Command Arguments requires something in the field aswell 

IlliasB22_0-1667384697771.png

 

Any help would be much appreciated 

5 REPLIES 5
DavidSkaife
13 - Pulsar

Hi @IlliasB22 

 

This is how i have had the Run Command tool setup to run Powershell scripts in the past:

 

DavidSkaife_0-1667385388072.png

 

Does that help?

curator_at_work
8 - Asteroid

but what to enter in input and output

apathetichell
19 - Altair

If you are writing a dynamic script -> output is the file Alteryx is writing to. You configure the dynamic script you write to in your workflow in output. You then reference in your command.

 

say your script is called runmyfile.bat -> you reference that in output and your command says runmyfile.bat -> in your case you are writing to a .ps1 file as plain text and then referencing it as a parameter for powershell.

curator_at_work
8 - Asteroid

Get-WmiObject Win32_LogicalDisk | Where-Object {$_.DriveType -eq 3} | Select-Object DeviceID, VolumeName, @{Name="Size(GB)";Expression={[math]::Round($_.Size/1GB,2)}}, @{Name="FreeSpace(GB)";Expression={[math]::Round($_.FreeSpace/1GB,2)}}, @{Name="FreeSpacePercent";Expression={[math]::Round(($_.FreeSpace/$_.Size)*100,2)}} | Format-Table -AutoSize | Out-File -FilePath "C:\Users\XXXXX\Downloads\server_disk_mgmt\DiskSpaceReport_txt.txt" -Encoding UTF8


above is the script to get the size of drive on PC, that i want to run in powershell through run command, i will save it as server.ps1 

output: file path of server.ps1 file
in command: powershell.exe
command argument:  file path of server.ps1


now what to give in input: 

i am using a text input befoer run command in whcih script is written

 

points: -

1: I am not running this script earlier, directly using in run command tool

apathetichell
19 - Altair

yes. I know. You should have a dummy script though. You should overwrite it with your actual script. @MeganBowers linked to a useful thread in your other post regarding this. Review how the output part is configured in the run command tool -> it's critical to get it to work.

 

once you have your script your command is powershell.exe -file {location of your file}

 

that is static. what is dynamic is the contents of your file which are outputting in the step above. try using a test script -> if it doesn't work examine your .ps1 file. what went wrong? did you include headers? did you include a delimiter? is your powersehll wrong?

Labels
Top Solution Authors