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.
Reader Level:

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.

Login to add your contents and source code to this article
post comment
     

Thank you:-)

Posted by Vijai Anand Dec 18, 2011

Good article. Thanks, for sharing your thought.

Posted by indramani gautam Dec 17, 2011

Nice article, Vijay.

Posted by Alok Harsh Dec 17, 2011
COMMENT USING
PREMIUM SPONSORS
Over-C is a holistic consortium of communications and technology specialists. We build, deploy and market both business as well as consumer products and solutions.
Join a Chapter
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.