Steps Involved:
- Open SharePoint 2010 Management Shell by going to Start | All Programs | SharePoint | Microsoft SharePoint 2010 Products | SharePoint 2010 Management Shell (Run as Administrator).
- Run the following script.
Powershell Script:
## Get the user group information for the specified groups using SharePoint 2010 web service in powershell $uri="http://serverName:10736/sites/ECT/_vti_bin/UserGroup.asmx?wsdl" ## $groupNamesXmlPath is the string that contains the xml path where all the group names are specified $groupNamesXmlPath="D:\\GroupNames.xml" $xmlDocument = New-Object -TypeName System.Xml.XmlDocument $xmlDocument.Load($groupNamesXmlPath) ## $groupNamesXml is a System.Xml.XmlNode object that specifies one or more group names for which the information has to be returned $groupNamesXml = $xmlDocument.DocumentElement
## Web Service Reference - http://Site/_vti_bin/UserGroup.asmx $usergroupWebServiceReference = New-WebServiceProxy -Uri $uri -UseDefaultCredential [System.Xml.XmlNode]$xmlNode=$usergroupWebServiceReference.GetGroupCollection($groupNamesXml)
## Creates an GroupCollection.xml file in the D:\ which contains the information for the specific groups $output = New-Object -TypeName System.IO.StreamWriter -ArgumentList "D:\GroupCollection.xml", $false $output.WriteLine("<?xml version=""1.0"" encoding=""utf-8"" ?>") $output.WriteLine($xmlNode.OuterXml) $output.WriteLine() $output.Dispose()
write-host -ForegroundColor Magenta "Displaying all the group names.........." foreach($group in $xmlNode.Groups.Group) { write-host -ForegroundColor Green $group.Name }
|
Input - GroupNames.xml:
Output :
Output - GroupCollection.xml: