SharePoint Online:如何禁用列表和库中的 Power Automate?
要求:禁用 SharePoint Online 中的“自动化”按钮。
Microsoft Flow 是一款出色的通过构建工作流程实现业务流程自动化的工具。在某些情况下,为了控制自定义,您可能需要通过隐藏 SharePoint Online 的现代列表和库中的“自动化”按钮来禁用流。
如何在 SharePoint Online 中禁用 Power Automate (Microsoft Flow)?
没有办法通过浏览器直接禁用 Power Automate,但我们必须使用 PowerShell 来实现!假设您的计算机上安装了最新的 SharePoint Online Management Shell,以下是如何通过 SharePoint Online Management Shell 禁用或启用 SharePoint Online 网站集中的流:
#Set parameter values
$AdminSiteURL="https://crescent-admin.sharepoint.com/"
$SiteURL="https://crescent.sharepoint.com/"
#Connect to SharePoint Online Admin Site
Connect-SPOService -Url $AdminSiteURL -Credential (Get-Credential)
# Disable flows on a site collection
Set-SPOSite -Identity $SiteURL -DisableFlows Disabled
#To Enable, use:
#Set-SPOSite -Identity $SiteURL -DisableFlows NotDisabled
这将关闭网站集的所有列表和库上的“自动化”。
但是,在群组连接的网站上,我发现它失败并显示“Set-SPOSite:https://crescent.sharepoint.com/sites/Purchase 是群组网站集”。
使用 CSOM 在 SharePoint Online 网站集上禁用流:
我们还可以使用 CSOM 脚本来关闭 SharePoint Online 中的流,而不是 SharePoint Online Management Shell。
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll"
#Set parameter values
$AdminSiteURL="https://crescent-admin.sharepoint.com/"
$SiteURL="https://crescent.sharepoint.com/"
$Cred= Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($AdminSiteURL)
$Ctx.Credentials = $Credentials
#Get the tenant object
$Tenant = New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($ctx)
#Get the current Settings for flow
$SiteColl=$Tenant.GetSitePropertiesByUrl($SiteURL, $true)
$ctx.Load($SiteColl)
$ctx.ExecuteQuery()
$SiteColl.DisableFlows
#Disable/Enable Flow
$SiteColl.DisableFlows = [Microsoft.Online.SharePoint.TenantAdministration.FlowsPolicy]::Disabled #To enable, set: NotDisabled
$SiteColl.Update()
$Ctx.ExecuteQuery()
这将禁用给定 SharePoint Online 现代网站中所有列表和库的 Microsoft Flow。您现有的所有流程将照常工作,但您将不再在界面中看到该按钮。不过,您仍然可以开始流过华夫饼!
在站点(子站点)上禁用自动化:
上述方法禁用整个网站集的 Microsoft 流。在某些情况下,您可能希望禁用特定子网站上的 Microsoft 流。这是我的 PowerShell 脚本,用于在特定站点上禁用 Microsoft Flow。
#Load SharePoint CSOM Assemblies
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\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#Set parameter values
$SiteURL="https://crescent.sharepoint.com/"
#Get Credentials to connect
$Cred= Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Credentials
#Disable flow on the Web (Root Web!)
$Web = $Ctx.Web
$Ctx.Load($Web)
$Ctx.ExecuteQuery()
#Disable Flow
$Web.DisableFlows= $true
$Web.Update()
$Ctx.ExecuteQuery()
使用 PnP PowerShell 禁用电源自动化
#Set Variables
$SiteURL = "https://crescent.sharepoint.com/sites/Sales"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)
#disable Microsoft Flow
Set-PnPSite -DisableFlows $True
结论
按照这些步骤,您可以为 SharePoint Online 中的特定网站集禁用 Power Automate。这对于想要限制 Power Automate 的使用或确保用户在 SharePoint Online 中自动化工作流时遵循特定业务流程的组织非常有用。请务必注意,停用 Power Automate 不会删除任何已创建的现有流。但是,用户将无法再从 SharePoint Online 中创建新流或访问现有流。

