Update Custom Roll Definition

Update role definition on all site collections in multiple web applications

$allWebApps = ("https://WEBAPP1", "https://WEBAPP2")
$updateRoll = "Site Manager"
# for each web app in the list of webapps)
foreach ($siteUrl in $allWebApps)
{
Write-Host "$siteUrl";
$rootSite = New-Object Microsoft.SharePoint.SPSite($siteUrl);
$spWebApp = $rootSite.WebApplication;
# for each site collection in the webapp
foreach($SPSite in $spWebApp.Sites)
{
Write-Host "$SPSite";
$OpenWeb = $SPSite.OpenWeb();
Write-Host "$OpenWeb";
$rolePerms = "ViewListItems,AddListItems,EditListItems,DeleteListItems,ApproveItems,OpenItems,ViewVersions,DeleteVersions,CancelCheckout,ManagePersonalViews,ManageLists,ViewFormPages,Open,ViewPages,AddAndCustomizePages,ViewUsageData,BrowseDirectories,BrowseUserInfo,AddDelPrivateWebParts,UpdatePersonalWebParts,UseClientIntegration,UseRemoteAPIs,ManageAlerts,CreateAlerts,EditMyUserInfo,EnumeratePermissions";
$collRoles = $OpenWeb.RoleDefinitions;
$oRoleDefinition = $collRoles[$updateRoll];
$oRoleDefinition.BasePermissions = $rolePerms;
$oRoleDefinition.Update();
$OpenWeb.Dispose();
}
$rootSite.Dispose();
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: