I am just beginning to use PowerShell in Power Automate Desktop. I have a fairly complex script that needs to run (creating a Microsoft Team) and I will need to pass various results back after the script finishes. Since I'm just starting, my script is only attempting to pass a variable straight through.
%TeamName% is an input variable that I set to "Test Team", then I call the PowerShell script, which is just this:
$TeamName = "%TeamName%"
write-output $TeamName
It looks like the issue is that I'm using the "Read text from file" action to read in the .ps1 script file into a variable, which is then executed by the script.
Is there a way to do this while still reading the script from a file? It is so much more convenient than having to edit the script in the little window. Right now, the script is just two lines, but the script I will need to run is much longer, so being able to use a script editor, just clicking "save", instead of clearing out the window and cutting and pasting the code is definitely desirable.
If you want to read the script from a file, your script will be stored as a literal text. You would then need to use Replace text to replace the placeholders in the script with actual variable values. I would suggest using some other notation in the script file and avoiding the percentage marks, as those will make it harder to replace it afterwards (you would need to escape the % by doing %% instead).
-------------------------------------------------------------------------
If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.
I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.
eetuRobo
11
Super User 2025 Season 1
KO-05050229-0
4
John_Mavridis
4
Microsoft Employee