Archive

Archive for November, 2014

SharePoint 2010: Get List of All Web Applicatons/Site Collections/Sub-Sites/Permissions and Last Modified using PowerShell

November 12, 2014 3 comments

#GET ALL WEB APPLICATIONS IN THE FARM
$webApp = Get-WebApplication

#FOREACH LOOP, LOOPING THROUGH ALL WEB APPLICATIONS IN THE FARM
foreach ($webApps in $webApp)
{

#WRITE-HOST WEB APPLICATION NAME
write-host “WEBAPP:” $webApps.Name

#FOREACH LOOP, LOOPING THROUGH ALL SITE COLLECTIONS WITHIN WEB APPLICATION
foreach ($site in $webApps.Sites)
{

#WRITE-HOST SITE COLLECTION URL
write-host “SITE: ” $site.URL

#FOREACH LOOP, LOOPING THROUGH ALL SITE COLLECTION ADMINISTRATORS
foreach ($siteAdmin in $site.RootWeb.SiteAdministrators)
{
#WRITE-HOST SITE COLLECTION ADMINS
write-host -foregroundcolor green “SITE COLLECTION ADMINS – $($siteAdmin.DisplayName)”
}

#FOREACH LOOP, LOOPING THROUGH ALL SUB-SITES IN SITE COLLECTION
foreach ($webs in $site.AllWebs)
{
#WRITE-HOST SUB-SITE NAME
write-host “SUB-SITE NAME:” $webs.Name
#WRITE-HOST SUB-SITES URL
write-host “SUB-SITES URL:” $webs.URL

#FOREACH LOOP, LOOPING THROUGH ALL ROLE ASSIGNMENTS IN THE WEB ROLE ASSIGNMENTS
foreach ($roleAssignment in $webs.RoleAssignments)
{
#FOREACH LOOP, LOOPING THROUGH ALL ROLE DEFINITIONS IN ROLE ASSIGMENT ROLE DEFINITIONS
foreach ($roleDefinition in $roleAssignment.RoleDefinitionBindings)
{
#IF STATEMENT (IF ROLE DEFINITION EQUALS FULL CONTROL)
if ($roleDefinition.Name -eq “Full Control”)
{
#WRITE-HOST PERMISSION LEVEL AND PERMISSION NAME
write-host -foregroundcolor red “Permission Level: ” $roleDefinition.Name “| Permission Name: “$roleAssignment.Member.Name
}
}
}

#FOREACH LOOP, LOOPING THROUGH ALL LISTS IN THE WEB
foreach ($list in $webs.Lists)
{
#WRITE-HOST LIST NAME AND LAST MODIFIED DATE
write-host “LIST NAME: ” $list.Title “| LAST MODIFIED DATE: ” $list.LastItemModifiedDate
}
}
}
}
}