Powershell to get al site collections name, url, ID, storage, SharePoint groups, all groups role, users from each group, users' email ID, primary owner, secondary owner, Created date, last modified date:
$rootSite = Get-SPSite http://test.sharepoint.com
$spWebApp = $rootSite.WebApplication
foreach($site in $spWebApp.Sites)
{
foreach($sites in $site.RootWeb)
{
$web = $site.OpenWeb()
$groups = $web.sitegroups
foreach ($grp in $groups)
{
$groupName = $grp.name
$role = $grp.ROles
foreach ($user in $grp.users)
{
write-host $sites.title, "User " $user.UserLogin, "Group: " $groupName, $role -foregroundcolor yellow
$sites.url + "$" + $sites.Title + "$" + $sites.ID + "$" + $Site.Usage.Storage + "$" + $groupName + "$" + $role + "$" + $user.UserLogin + "$" + $user.Name + "$" + $user.Email + "$" + $Site.Owner.Name + "$" + $Site.Owner.Email + "$" + $Site.SecondaryContact.Name + "$" + $Site.SecondaryContact.Email + "$" + $sites.Created + "$" + $sites.lastitemmodifieddate | out-file "E:\SiteCollectionreport.csv" -Append
}
}
}
$web.Dispose()
$site.Dispose()
}