SharePoint 2010 - Retrieve the Permission Mask Values for a Site using Powershell

This article stems from another article explaining how to Automate Site & Group Creation with Nintex Workflow 2010

What
Use Powershell to retrieve detailed data about the permission levels on a particular site

Why
I was looking for a way to automate Site & Group creation using nintex workflows.  In order to create groups, you need to call a SharePoint Web Service.  That Web Service requires an input value called 'permissionMask (int)'.

This powershell script will allow you to find the correct permission Mask related to your particular environment & permission levels.

How
Jump onto your WFE, open up SharePoint Powershell as admin and paste in the following code (with the site you wish to retrieve data for:

## Get site permissions using SharePoint 2010 web service in powershell
$uri="http://rootsite/subsite/_vti_bin/Permissions.asmx?wsdl" 
## $siteName is a string which contains the site name for which you need to get the permissions
[String]$siteName="site name"
## $type is a string which contains the object type - List
[String]$type="Web"

## Web Service Reference - http://rootsite/subsite/_vti_bin/Permissions.asmx
$permissionWebServiceReference = New-WebServiceProxy -Uri $uri -UseDefaultCredential 
[System.Xml.XmlNode]$xmlNode=$permissionWebServiceReference.GetPermissionCollection($siteName,$type)

## Creates an GetSitePermissions.xml file in the D:\ which contains the permissions for the site
$output = New-Object -TypeName System.IO.StreamWriter -ArgumentList "C:\temp\GetSitePermissions.xml", $false
$output.WriteLine("<?xml version=""1.0"" encoding=""utf-8"" ?>")
$output.WriteLine($xmlNode.OuterXml)
$output.WriteLine() 
$output.Dispose()

Once the script has run, navigate to C:\Temp and grab the Mask value against the group that has the permissions you want to mimic.


Credit where it's due
Vijai for providing the code: http://www.c-sharpcorner.com/blogs/get-site-permissions-using-sharepoint-2010-web-service-in-powershell

Comments

Popular posts from this blog

SharePoint - Field type [FieldName] is not installed properly. Go to the list settings page to delete this field.

Export Group Membership From Active Directory Using Power Query

Office 365 Groups - Quickly find the GUID of a O365 Group