$site = Get-SPSite “http://yoursite”
foreach ($web in $site.AllWebs) {
$web | Select-Object -Property Title,Url,WebTemplate
}
$site.Dispose()
$site = Get-SPSite “http://yoursite”
foreach ($web in $site.AllWebs) {
$web | Select-Object -Property Title,Url,WebTemplate
}
$site.Dispose()
Background:
I wanted to see all users who have access to the SharePoint site and belongs to which SharePoint group.
Solution:
Below SharePoint powershell script helps me to get list of users group wise-
$site = Get-SPSite <Provide Site Collection URL here>$web = $site.OpenWeb()$groups = $web.sitegroupsforeach ($grp in $groups) { "Group: " + $grp.name; $groupName = $grp.name write-host "Group: " $groupName -foregroundcolor green foreach ($user in $grp.users) { "User: " + $user.name write-host "User " $user.UserLogin -foregroundcolor red }} Usage:
GetUsers.ps1
This will show output on screen.
GetUsers.ps1 | Out-File C:Output.csvThis will generate output as csv file. “C:Output.csv” is the file name and location where generated csv file is saved. Please change as per your requirement.
One of the features of SharePoint that has been around is the ability for users that need access to a site, and are denied access, through the “Request Access” process.
To enable or review these settings,
If a site has multiple groups with the same permission levels (Owners, Members and Viewers) but there is not an assigned default group, then you will see the problem where access requests will either not display for the impacted user or an owner will not be able to approve requests.
Here’s a Windows PowerShell script to change each of the groups for a site so that each is identified as the default group for Members, Owners and Visitors
You’ll need to a the “Microsoft.SharePoint.PowerShell” add-in at the top of the script to get the SharePoint references.
#Members Group
$web = Get-SPWeb “https://sharepoint.contoso.com”
$groupToMakeDefaultMembersGroup = $web.Groups | ? { $_.Name -eq “Team Site Members” }
$web.AssociatedMemberGroup = $groupToMakeDefaultMembersGroup
$web.Update()
#Owners Group
$web = Get-SPWeb “https://sharepoint.contoso.com”
$groupToMakeDefaultOwnersGroup = $web.Groups | ? { $_.Name -eq “Team Site Owners” }
$web.AssociatedOwnerGroup = $groupToMakeDefaultOwnersGroup
$web.Update()
#Visitors Group
$web = Get-SPWeb “https://sharepoint.contoso.com”
$groupToMakeDefaultVisitorsGroup = $web.Groups | ? { $_.Name -eq “Team Site Visitors” }
$web.AssociatedVisitorGroup = $groupToMakeDefaultMembersGroup
$web.Update()
#Enable Access Requests after it was disabled
$web.RequestAccessEmail = “user@mydomain.com”
$web.Update()
If you turn off the feature, you will can re-enable the feature by adding an email address to the “RequestAccessEmail” property.
Hope this helps solving the problem around assigning default groups and enabling the Request Access feature in SharePoint 2013.