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()
}
Sunday, April 9, 2017
Wednesday, April 5, 2017
Powershell to get all site collection site template
The below script can be used to extract the list of all site collection, its title, URL, Template, Template ID from a specific web application:
$rootSite = Get-SPSite "link of specific web application"
$spWebApp = $rootSite.WebApplication
foreach($site in $spWebApp.Sites)
{
foreach($sites in $site.RootWeb)
{
write-host $sites.url , $sites.Title , $sites.WebTemplate , $sites.WebTemplateId
$sites.url + "$" + $sites.Title + "$" + $sites.WebTemplate + "$" + $sites.WebTemplateId | out-file "G:\Scripts\Outputs\SPTemplates.csv" -Append
}
}
$web.Dispose()
$site.Dispose()
$rootSite = Get-SPSite "link of specific web application"
$spWebApp = $rootSite.WebApplication
foreach($site in $spWebApp.Sites)
{
foreach($sites in $site.RootWeb)
{
write-host $sites.url , $sites.Title , $sites.WebTemplate , $sites.WebTemplateId
$sites.url + "$" + $sites.Title + "$" + $sites.WebTemplate + "$" + $sites.WebTemplateId | out-file "G:\Scripts\Outputs\SPTemplates.csv" -Append
}
}
$web.Dispose()
$site.Dispose()
Subscribe to:
Posts (Atom)