Tuesday, April 9, 2013

Add Web Application User Policy using PowerShell in SharePoint

SharePoint web application user policy is the ideal way to manage permissions at the web application level instead of individual site collections. E.g. You want to provide full control to your CIO to all site collections in a intranet web application. Web app policy is discussed in my another article: SharePoint web application policy

Add Web Application Policy using PowerShell

How to Create Web Application Policy in SharePoint using PowerShell?
This PowerShell script adds new user policy to web application.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$WebAppURL = "http://sharepoint.crescent.com"
$UserID = "Global\EricConnell"
$UserDisplayName = "Global CIO"

#Get the Web Application
$WebApp = Get-spwebapplication $WebAppURL

#Convert the UserID to Claims - If your Web App is claims based!!!
 $UserAccount = (New-SPClaimsPrincipal -identity $UserID -identitytype 1).ToEncodedString()

#Create FULL Access Web Application User Policy
$ZonePolicies = $WebApp.ZonePolicies("Default")

#Add sharepoint web application user policy with powershell
$Policy = $ZonePolicies.Add($UserAccount,$UserDisplayName)

Write-Host "Web Application Policy for $($UserDisplayName) has been Granted!"
GetSpecialRole() function in SharePoint can take enumerations from : [Microsoft.SharePoint.Administration.SPPolicyRoleType], Such as: FullControl, FullRead, etc.

Here is my another article which adds Full Read and Full control web application user policies using Central Administration site and PowerShell: Powershell to Add web application user policy in SharePoint

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...