I have searched high and low trying to figure out how to output the results for a simple PowerShell script file named Admin.ps1 that contains the cmdlet Get-ADDefualtDomainPasswordPolicy from the Run Command tool to an output tool, in this case the Browse tool. However, when I do this I get this well documented error.
All of the solutions I've read indicate you have to identify a Read source when you have a Write Source, even if it’s not technically necessary. So, in my workflow I made the Admin.ps1 file the read source and now workflow runs and I can see PowerShell opening and running with no error codes returned.
However, what appears in the Browse tool is the Cmdlet found in the Admin.ps1 file. This is obviously not what I want. I want to see the results from the Cmdlet.
If anyone can show me how to do this, you're automatically on my Christmas list.
Solved! Go to Solution.
@john_dwyer - Read results in run command reads a file. You have to have your powershell write the results to a file. You then have your run commmand read that file.
what I ended up doing was using a BUD to write/run my bat command - cand create a file via:
"aws secretsmanager get-secret-value --secret-id arn:aws:secretsmanager:{{secretARN}} >"+[filename] (with [filename] being a tempdirectory location)
I then read that in a macro via input data and parse the json.
@john_dwyer have you checked this article: https://knowledge.alteryx.com/index/s/article/How-To-Use-PowerShell-with-Alteryx-1583460190246
if that doesn't work, I'll have a look at this one https://community.alteryx.com/t5/Alteryx-Designer-Desktop-Discussions/Running-Powershell-script-in-D... and see if there's anything good in there.
I'll have a quick play around and see if I can get it working.
All the best,
BS
I've never had to solve this type of problem. Hopefully this is useful.
I guess this doesn't call on the script directly but does it via the formula tool in Alteryx.
I'll attach the workflow. As well.
I needed to ensure the delimiter in the file that's being written out was \0 as this was causing mega issues. Also, via powershell, Set-ExecutionPolicy RemoteSigned.
This is as far as I can take it for today @john_dwyer ..
all the best,
BS
If you're wanting to read a script in, for now, I would read that into Alteryx directly as a .txt/.csv file and feed it through to the command prompt.
Probably butchered the solution completely 😂.
But hey, it seems to work.
All the best,
BS
The problem is that when I read the script into the run command as a .txt, .csv, .xlxs, etc. and connect an output tool to the run command tool, it passes on the script and not the output from the script
Thank but but I didn't understand the proposed solution. Would it be possible for you to provide an extremely simple yxmd example where the Run Command tool output was passed to the connected to the Browse tool?
Check the picture above. That's my Powershell script file on the left. It asks powershell to return the current date/time and also append another command saying "hello" onto the file.
I read this powershell script into the workflowflow as a csv; summarize and concatenate it to a single cell so this can be passed into the command tool. The command tool then writes the single cell out into a powershell script file (temporarily) then it reads it back in. This is then executed using Powershell.
Powershell stores the results in a .txt file (which I specified for it to do in my initial powershell script; you can check the picture above). I then read these results back in (read results option in command tool).
This should also work for your use case as it seems you just want to execute a script and pull the response from powershell into alteryx.
Let me know how it goes @john_dwyer
All the best,
BS
It worked! This is exactly what I was looking for. I can/will definitely be able to build off of this working example. Thank you!!!