This exists on the RoleAssignment.Groups property.
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.associatedgroups.aspx
# Note -- I have a function for creating the context.
$Ctx = Get-Context $Credentials $SubSiteURL
$Ctx.Load($Ctx.Web.RoleAssignments.Groups)
$Ctx.ExecuteQuery()
ForEach($Group in $Ctx.Web.RoleAssignments.Groups)
{
$Ctx.Load($Group)
$Ctx.ExecuteQuery()
Write-Output ("{0} -> {1} -> {2}" -f $Group.Id, $Group.Title, $Group.Description)
}
Output:
3 -> Excel Services Viewers -> Members of this group can view pages, list items, and documents. If the document has a
server rendering available, they can only view the document using the server rendering.
7 -> IT TEST AREA Members ->
5 -> IT TEST AREA Owners ->
6 -> IT TEST AREA Visitors ->
21 -> SharingLinks....OrganizationEdit.... -> This group is for OrganizationEdit sharing links on item 'DocURL'
26 -> TESt Members -> Use this group to grant people contribute permissions to the SharePoint site: TESt
27 -> TESt Visitors -> Use this group to grant people read permissions to the SharePoint site: TESt
Just write something to iterate through all items under the root web, like this.
Function Get-SubSites($Credentials, $SiteURL)
{
# Check if this is the parent web or not
$Context = Get-Context $Credentials $SiteURL
$Context.Load($Context.Web.Webs)
$Context.ExecuteQuery()
# Collect whatever you want and append it to an array
$Report += $Context.Web.Url
ForEach($Web in $Context.Web.Webs)
{
Get-SubSites $Credentials $Web.Url
}
$Context.Dispose()
}
$Script:Report = @()