Monday 9 July 2012

How to list all the Site Collection Admins into a specific Web Application in Shp2007


Hi all,

Today’s challenge, is to list all the SCA’s of a Web App.

With google, I found a nice simple post on "The Frog Pond of Technology" with a little powershell script.
Then, I found a link to the Brian T. Jackett TechNet Script Repository , and tested his script, with a little change, explained by Tasha’s feedback in the first link (I got the same blank names).

So, hereunder is the script that I’m now using to grab all the SCA’s in the needed WA.

########################################################### #SP_Display-SiteCollectionAdmins1.ps1 -URL # #Author: Brian T. Jackett #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] function GetMissingParameter { $script:siteUrl = Read-Host "Enter Site URL" } ############ # MAIN ############ #IF MISSING PARM FOR SITE URL, ASK FOR INPUT TO FILL if($args.length -eq 0) { GetMissingParameter } $rootSite = New-Object Microsoft.SharePoint.SPSite($siteUrl) $spWebApp = $rootSite.WebApplication foreach($site in $spWebApp.Sites) { foreach($siteAdmin in $site.RootWeb.SiteAdministrators) { Write-Host "$($siteAdmin.ParentWeb.Url) - $($siteAdmin.Name)" Write-Output "$($siteAdmin.ParentWeb.Url) - $($siteAdmin.Name)" |Out-File -encoding default -append } $site.Dispose() } $rootSite.Dispose()


nb: added the output to a file



I didn’t test this script in SharePoint 2010, but it is said that this script in object model will work for 2007 and 2010.


That's all folks.

No comments:

Post a Comment