Power Automate meets PowerShell in Azure

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.

SharePoint External Sharing Disabled

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.

My runbook with PowerShell Script

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.

Built on my personal Dev tenant with an Azure Trial

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.

Share