#SP_Display- SiteCollectionAdmins1.ps1 -URL <string>
#
#Author: SharePoint
#Last Modified Date: Mar. 25, 2011
#
#Display all site collection admins for all site collections
# within a web application.
############################## #############################
#
#Author: SharePoint
#Last Modified Date: Mar. 25, 2011
#
#Display all site collection admins for all site collections
# within a web application.
##############################
[void][System.Reflection. Assembly]:: LoadWithPartialName(' Microsoft.SharePoint')
#DECLARE VARIABLES
[string]$siteUrl = $args[0]
[string]$siteUrl = $args[0]
function GetMissingParameter
{
$script:siteUrl = Read-Host "Enter Site URL"
}
{
$script:siteUrl = Read-Host "Enter Site URL"
}
############
# MAIN
############
# MAIN
############
#IF MISSING PARM FOR SITE URL, ASK FOR INPUT TO FILL
if($args.length -eq 0)
{
GetMissingParameter
}
if($args.length -eq 0)
{
GetMissingParameter
}
$rootSite = New-Object Microsoft.SharePoint.SPSite($ siteUrl)
$spWebApp = $rootSite.WebApplication
$spWebApp = $rootSite.WebApplication
foreach($site in $spWebApp.Sites)
{
foreach($siteAdmin in $site.RootWeb. SiteAdministrators)
{
Write-Host "$($siteAdmin.ParentWeb.Url) - $($siteAdmin.DisplayName)"
}
$site.Dispose()
}
$rootSite.Dispose()
{
foreach($siteAdmin in $site.RootWeb.
{
Write-Host "$($siteAdmin.ParentWeb.Url) - $($siteAdmin.DisplayName)"
}
$site.Dispose()
}
$rootSite.Dispose()
No comments:
Post a Comment