I never knew how this worked or that it even existed until I attended the Global Automation Bootcamp today and saw demos by both Ben Stegink and Jaap Brasser who gave me the confidence to try building a PowerShell Azure Runbook which can be called from Power Automate using the Azure Automation Create Job Step.
My employer has a policy where all new SharePoint sites are setup with external sharing disabled and the only way to change this setting (as of today) is via the Admin GUI or PowerShell. We have a requirement to change the default setting to existing guests if manager approval has been granted, PowerAutomate has Approvals built in. This is the perfect opportunity for PowerShell to meet PowerAutomate.

I have previously used SharePoint Powershell CMD Lets to manage SharePoint Online and so thought I would fully automated this process.
First off, I have created an Azure Automation Account that then allowed me to create a RunBook specifically for the task ahead. The CMD Let I am looking to run is Set-SPOSite. I accept a variable input for the Site URL and in return I have some error handling and confirmation of the changes made to the SharingCapability setting.

Calling the PowerShell Automation is straight forward. Make a connection to Azure Automation Connector and then select Create Job. I have chosen for the step to wait for the job to complete and then get the job output which includes a JSON of the outcome and the various settings retrieved from GET-SPOSITE.

This opens up so many opportunities. My next job is to manage dormant guests that are on our tenant. I wrote a PowerShell script months ago that can be run manually, but now I have the excuse to fully automate it thanks to another great weekend of demonstrations.
If you have any ideas for this technology, please get in touch. I will happily build you a proof of concept in order to supplement my blog and my learning.
Hello,
as always very interesting your posts, articles, …
I’m using this connector ‘Create job’ also to run several runbooks I have on Azure Automations. They work fine, as expected; but once I move the Solution to a Prod environment there is no way to work with it. This connector raises an error “Failed to retrieve dynamic inputs. Error details: ‘Request to Azure Resource Manager failed with error: ‘{“Code”:”NotFound”,”Message”:”Cannot find connection with name xxx-xxx-xxx”
; no way to fix this error, no way to Turn the flow on.
Any help on that? Thank you very much in advance.