Reset WebApplication Rights Mask To FullMask

Script

Name

Description

Last Modified Date

Download

ResetWebApplicationRightsMaskToFullMask.ps1

 Reverts the rights mask property on a web application to 
full mask (the original non-modified value)
02/05/2013

None

Issue

An issue occurred with an implementation of TRIM Context into SharePoint.  The TRIM configuration components checked for the FullMask permissions for the service accounts.

In this case the web application had its permissions modified and while all permissions had been restored, SharePoint does not restore the original FullMask value.  

Thanks to Cornelius J. van Dyk for his post on this issue.  The following script is based on his post, but with a few changes. 

# Name: ResetWebApplicationRightsMaskToFullMask.ps1
# Purpose: Reverts the rightsmask property on a web application to full mask (the original non-modified value)
param
( 
	[string]$webAppUrl = $(read-host "Specify a URL for the web application to update")
)
try
{
	if([string]::IsNullOrEmpty($webAppUrl)) {throw "Cannot proceed without valid web application url"}
	$wa = get-spwebapplication $webAppUrl
	if($wa -eq $null)	{throw ("Cannot locate web application at url: " + $webAppUrl)}
	$wa.RightsMask = [Microsoft.SharePoint.SPBasePermissions]::FullMask
	$wa.Update()
	Write-Host "Web application $webAppUrl rights mask updated to: " $wa.RightsMask " (" $wa.RightsMask.value__ ")"
}
catch
{
	Write-Host -f Red "Error $_"
	exit 9999
}

CodeMonkey Software is a division of JCHMedia www.jchmedia.com