kwizcom banner advertisement

Remove SharePoint Web Application Policy using PowerShell

Requirement: Remove Web Application Policy using PowerShell

How to remove a web application Policy in SharePoint?
To remove a user or group from SharePoint web application Policy, follow these steps:
  • Login to SharePoint Central Administration Site
  • Application Management >> Manage Web Applications 
  • Select the appropriate web application from the list >> Click on "User Policy" button from the ribbon. 
    delete web application policy in sharepoint
  • Now, from the "Policy for Web Application" page, Select the user or group to remove and click on "Delete Selected Users" link
  • Confirm the prompt once to remove select accounts from web application Policy.
    remove web application policy using powershell
PowerShell to Remove a Web Application Policy in SharePoint:
Here is the PowerShell script to delete a web application policy in SharePoint.
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
        }
        #Remove web application Policy
        $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 "http://intranet.crescent.com/" -Account "i:0#.w|crescent\salaudeen"

To Add a web application policy in SharePoint, use this PowerShell script: SharePoint PowerShell to Add Web Application User Policy
Remove SharePoint Web Application Policy using PowerShell Remove SharePoint Web Application Policy using PowerShell Reviewed by Salaudeen Rajack on April 20, 2017 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.