使用 PowerShell 删除 SharePoint Web 应用程序策略
要求:使用 PowerShell 删除 Web 应用程序策略。
如何删除 SharePoint 中的 Web 应用程序策略?
在 SharePoint 中,可以在 Web 应用程序级别应用用户策略来控制特定用户或组对资源的访问。 PowerShell 和 Central Admin 提供了一种更简单的方法来管理 SharePoint 中 Web 应用程序的用户策略。
要从 SharePoint Web 应用程序策略中删除用户或组,请执行以下步骤:
- 登录到 SharePoint 管理中心站点。
- 应用程序管理 >> 管理 Web 应用程序。
从列表中选择适当的 Web 应用程序 >> 单击功能区中的“用户策略”按钮。
- 现在,从“Web 应用程序策略”页面中,选择要删除的用户或组,然后单击“删除所选用户”链接。
-
确认一次提示,从 Web 应用程序策略中删除选定的帐户。
使用 PowerShell 删除 SharePoint 中的 Web 应用程序策略:
您可以使用 PowerShell 来管理 SharePoint Web 应用程序策略。让我们看看如何使用 PowerShell 删除 Web 应用程序策略。
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
Function Remove-WebAppPolicy($WebAppURL, $Account)
{
Try {
Write-host "Removing Account '$Account' from the Web Application '$WebAppURL'..." -f yellow
#Get the web application
$WebApp = Get-SPWebApplication $WebAppURL -EA SilentlyContinue
#Check if web application Exists
if ($WebApp -eq $null)
{
$ErrorMsg = "Web Application " + $WebAppURL + " not found!"
Throw $ErrorMsg
}
#PowerShell to delete a web application policy in SharePoint
$Policy = $webApp.Policies.Remove($Account)
$WebApp.Update()
Write-host "Web Application Policy Removed Successfully! " -f green
}
Catch {
Write-host -f Red "Error Deleting Web Application Policy:" $_.Exception.Message
}
}
#Call the function to remove web application Policy
Remove-WebAppPolicy -WebAppURL "https://intranet.crescent.com/" -Account "i:0#.w|crescent\salaudeen"
通过执行本文中概述的步骤,您可以使用 PowerShell 轻松从 SharePoint 中 Web 应用程序的用户策略中删除用户或组。要在 SharePoint 中添加 Web 应用程序策略,请使用此 PowerShell 脚本:SharePoint PowerShell 添加 Web 应用程序用户策略

