Reader Level:
ARTICLE

Get all the role definitions for the SharePoint 2010 site using web service in powershell

Posted by Vijai Anand Articles | SharePoint 2010 December 16, 2011
In this article you will see how to get all the role definitions for the SharePoint 2010 site using a web service in powershell.
  • 0
  • 0
  • 7749

In this article you will see how to get all the role definitions for the SharePoint 2010 site using a web service in powershell.

Navigate to the SharePoint site. Go to Site Actions, click on Site Settings. In the Users and Permissions section click on Site Permissions. In the ribbon interface click on Edit tab. In the Manage group, click on Permission Levels button. You could be able to see all the role definitions as shown in the following figure.

Share1.jpg

In this you will see how to get all the above role definitions using SharePoint 2010 web service in Powershell.

Steps Involved:

  1. Open SharePoint 2010 Management Shell by going to Start | All Programs | SharePoint | Microsoft SharePoint 2010 Products | SharePoint 2010 Management Shell (Run a
    Administrator).
     
  2. Run the following script.

Powershell Script:


    ## Get all the role definitions from the site using SharePoint 2010 web service in powershell
      $uri="http://serverName:10736/sites/ECT2/_vti_bin/UserGroup.asmx?wsdl"       

      ## Web Service Reference - http://Site/_vti_bin/UserGroup.asmx
      $usergroupWebServiceReference = New-WebServiceProxy -Uri $uri -UseDefaultCredential
    [
System.Xml.XmlNode]$xmlNode=$usergroupWebServiceReference.GetRoleCollectionFromWeb()

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


Result:

Share2.jpg

Summary:

Thus in this article you have seen how to get all the role definitions from the SharePoint 2010 site using web service in powershell.

COMMENT USING

Trending up