Now, now, I know what you’re thinking, “This is a terrible idea! Why would any want to disable Flow?? What’s Flow ever done to them anyway?” I’m right there with you, honest I am, but a customer asked me how to do this and I can’t imagine they’re the only ones trying to do it. So while I’m a big fan of Flow and think everyone should enjoy it, in the unlikely event your organization doesn’t want to, here’s how to disable it.
When things are in their default state, the Ribbon, or Toolbar in a Modern List or Document Library in Office 365 shows an easy to use link to wire up a Flow to the library. It looks like this:
Very cute, very innocent, but regardless, some folks don’t want it there. Even if the user hitting the list or library isn’t licensed to use Flow, it’s there. This is a per site collection setting, and nowhere in the site or site collection settings is there a place to shut it off. I turned on the Bat Signal, and PowerShell answered my call. Sort of…
The official Microsoft SharePoint Online cmdlets have a cmdlets, Set-SPOSite and it has a parameter, –DisableFlows. Are you thinking what I’m thinking? Of course you are. And it does what we want, kind of. Here’s how the whole solution looks:
Connect-SPOService -Url https://flowhater-admin.sharepoint.com
$val = [Microsoft.Online.SharePoint.TenantAdministration.FlowsPolicy]::Disabled
Set-SPOSite -Identity https://flowhater.sharepoint.com/sites/Me2Hub -DisableFlows $val
You have to do the funny business with $val because the –DisableFlows parameter doesn’t accept a boolean, like a civilized parameter does, it requires its value to be in the form of a Microsoft.Online.SharePoint.TenantAdministration.FlowsPolicy object, whatever that is. So that’s what it gets.
Now when we go to our Document Library it looks like this:
Sad, I know. When you come to your senses and want to reenable Flow, here’s how you do it:
$val = [Microsoft.Online.SharePoint.TenantAdministration.FlowsPolicy]::NotDisabled
Set-SPOSite -Identity https://flowhater.sharepoint.com/sites/Me2Hub -DisableFlows $val
And now is all right in the world.
Unless you have the fancy Site Collections that are using Groups in the background. Then you get the “womp womp” sound from Set-SPOSite. Okay, it really says, “Set-SPOSite : https://flowhater.sharepoint.com/sites/SPODemo2-Test2 is a Groups site collection.” but we all know what it really means. A less motivated man would have given up at this point. He would have taken this as a sign from the universe that one should not be disabling Flows, it’s just unnatural. Not this man. (In reality, not this man’s customer). So I went to Plan B, the PnP PowerShell, and it did not disappoint. The PnP’s version of the Set-Site cmdlet works with Group Site Collections and doesn’t require any weird casting voodoo. Here’s how it looks:
Connect-PnPOnline -Url https://flowhater.sharepoint.com/sites/SPODemo2-Test2 -Credentials 'SteffenAdmin'
Set-PnPSite -DisableFlows:$true
Here’s how you right that wrong:
Set-PnPSite -DisableFlows:$false
That’s much easier, and works on all site collections.
There you have it. I hope you never have to use it. 
Edit: This does not work with Group connected sites.
tk
ShortURL: https://www.toddklindt.com/PoshDisableFlowButton