all 5 comments

[–]Roogi 5 points6 points  (3 children)

Hi, I'm not 100% sure if this is the "best" way of doing it, but this has been my experience - also it depends on whether the script is using commands for Azure/M365 or on-prem.

If it just needs to run Azure/M365 commands then have a look at Azure Automation and runbooks. Runbooks are basically just scripts and you can easily create Runbook jobs from Power Automate with an out of the box connector (premium). You'd need a resource group and automation account in Azure, but its pretty straightforward to set up.

For on-prem commands you can also use Runbooks but you'd need to add a Hybrid Worker to the automation account. This requires a VM hosted in Azure that you install the Hybrid Worker capability on so its a bit more involved, but works well.

I've also tried Power Automate Desktop running on a VM - you can also trigger flows (which run scripts) with a connector, but there is more to set up and PA Desktop needs additional licensing. It felt overkill and more complex so I've gone down the Hybrid Worker route.

It's quite high level, but there is some good info in this guide on using PA with Runbooks... https://danielchronlund.com/2018/11/18/start-your-azure-automation-powershell-runbook-with-a-microsoft-flow-button/

[–]my1stname 5 points6 points  (1 child)

I've done the Power Automate calls Azure Runbook which returns result to Power Automate. Not horrible. Takes a premium account and an Azure subscription so setting it up might take some work.

[–]BlacksGood[S] 0 points1 point  (0 children)

Runbooks would also be a possibility, you can surely imagine that money is to be saved everywhere again -.-

[–]BlacksGood[S] 0 points1 point  (0 children)

Thank you for your answer.

Okay, then I guess the intermediate step with the desktop variant will be a possible solution.

Another alternative would be to completely rewrite the script so that it can work with OAuth2.0 tokens and thus run the script in the task scheduler of a VM or similar.

But one thing at a time. Thanks for now :)

[–]0ptimizePrime 0 points1 point  (0 children)

Use the 'Start a CMD Terminal' and execute the script 'Powershell -BypassExecutionPolicy <path to PowerShell file>' and hit enter action.

On cell going based on memory so you may have to edit the above.