What is Flows Policy?

Flows Policy is a site setting that enables or disables Flows for all lists and libraries in the site. By default, the Flows are enabled. The property is named .DisableFlows and was added in August 2016 CSOM update. It accepts three values from FlowsPolicy enumeration:

  • Unknown
  • Disabled
  • NotDisabled

When the property is set to NotDisabled, the lists in the site have Flow button:

When the property is set to Disabled, the Flow button disappears from the ribbon:

SharePoint Online Management Shell

Prerequisites

Make sure you have SharePoint Online Management Shell installed. The Shell is available for download from Microsoft Download Center.

Modify

In order to change the DisableFlows property connect to SharePoint:

and use the Set-SPOSite cmdlet to enable flows:

Set-SPOSite -Identity 'https://cfschulung.sharepoint.com' -DisableFlows NotDisabled

or disable flows:

Set-SPOSite -Identity 'https://cfschulung.sharepoint.com' -DisableFlows Disabled

CSOM

The .DisableFlows property can be also verified or updated with Powershell and CSOM.

Prerequisites

Use the correct libraries. The property was added in the August 2016 version of CSOM package, which is 16.1.5626.1200. Make sure you are using this or a later one. This sample is using a later version: 16.0.6518.1200

Verify

1. Open PowerShell or PowerShell ISE and add the libraries:

Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\SharePoint Client Components\16.0\Assemblies\Microsoft.Online.SharePoint.Client.Tenant.dll"
 

2. Create a client context and run .ExecuteQuery() to verify the credentials and connection settings:

$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Adminurl)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username$password)
$ctx.ExecuteQuery()

3. Create a tenant object:

$spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx)

4. Get the site properties.

In place of $url variable enter the URL of the site where you want to disable or enable the flows:

$siteColl=$spoTenant.GetSitePropertiesByUrl($Url$true)
$ctx.Load($siteColl)
$ctx.ExecuteQuery()

5. Display the site properties:

Write-Output $siteColl

Modify

1. Open PowerShell or PowerShell ISE and add the libraries:

Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\SharePoint Client Components\16.0\Assemblies\Microsoft.Online.SharePoint.Client.Tenant.dll"
 

2. Create a client context and run .ExecuteQuery() to verify the credentials and connection settings:

$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Adminurl)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password)
$ctx.ExecuteQuery()

3. Create a tenant object:

$spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx)

4. Get the site properties.

In place of $url variable enter the URL of the site where you want to disable or enable the flows:

$siteColl=$spoTenant.GetSitePropertiesByUrl($Url, $true)
$ctx.Load($siteColl)
$ctx.ExecuteQuery()

5. Disable/Enable flows:

Disable:

$siteColl.DisableFlows= [Microsoft.Online.SharePoint.TenantAdministration.FlowsPolicy]::Disabled
$siteColl.Update()
$ctx.ExecuteQuery()

or enable them:

$siteColl.DisableFlows= [Microsoft.Online.SharePoint.TenantAdministration.FlowsPolicy]::NotDisabled
$siteColl.Update()
$ctx.ExecuteQuery()

REST

Verify - Browser 

Using REST endpoints you can verify whether the Flows are enabled or disabled even in your browser. Just type the URL of the site and add /_api/site at the end:

Verify - PowerShell

The upside of using REST API is that you do not need the updated .dll libraries to verify the property.

In place of $RESTUrl variable use the url of your site + "/_api/site", e.g. https://TENANT.sharepoint.com/_api/site  or https://TENANT.sharepoint.com/sites/SITECOLL/_api/site

$request = [System.Net.WebRequest]::Create($RESTUrl)
$request.Credentials = $Credentials
$request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f")
$request.Accept = "application/json;odata=verbose"
[Microsoft.PowerShell.Commands.WebRequestMethod]$Method = [Microsoft.PowerShell.Commands.WebRequestMethod]::Get
$request.Method=$Method
$response = $request.GetResponse()
$requestStream = $response.GetResponseStream()
$read = New-Object System.IO.StreamReader $requestStream
$data=$read.ReadToEnd()
$results = $data | ConvertFrom-Json
Write-Output $results.d

Download

Scripts related to this article have been published in the TechNet Gallery and are available for download here:

See Also

website statistics