how to get the site admin list of all site collections
Hi, I have around 1000 site collections, need to get the list of all site admins of those sites and subsites.Is there any way to get all the site admins in one single shot through reports or some other thing. regards, ShwetaMe
August 9th, 2011 2:50am

You could easily write a PowerShell script for this. Using PS, instantiate an object for the Web Applications, grab all its Site Collections, and then identify the admins from there. There are a couple books out there on using PowerShell w/SharePoint, and also check out Gary Lapointe's blog here, as he has a ton of PowerShell stuff. Hope that helps - M Michael Mukalian | Jan 2010 - Dec 2010 MVP SharePoint Services | MCTS: MOSS 2007 Configuration | http://www.mukalian.com/blog
Free Windows Admin Tool Kit Click here and download it now
August 10th, 2011 3:29am

There is no stsadm command to pull this information from sharepoint. You can either write a console application using Object Model which will loop through all sites and subsites in your web-application and provide you with a report or you can use powershell scripting to do the same.Thanks & Regards, Soumyadev | Posting is provided "AS IS" with no warranties, and confers no rights.
August 10th, 2011 4:03am

Hi Michael, I am still usin MOSS 2007 so not possible to use powershell script.is there any other way apart from this. regards, ShwetaMe
Free Windows Admin Tool Kit Click here and download it now
August 10th, 2011 7:46am

PowerShell can be used w/SharePoint 2007, you just cannot use the SharePoint 2010 cmdlets. You can still utilize the object model, from PowerShell, to acheive what you're looking for. If your SP machine is installed on Windows Server 2008 R2, you'll have the correct version of PowerShell. If you are on Server 2003, you'll have to do a quick download and install. This is all possible as we are doing a lot of PowerShell work on an existing SP 2007 implementation currently. Since we installed PowerShell the admiistration/maintenance has become much easier. I previously put out a post on my blog on how to delete all versions of a document using PowerShell, and this works in SP 2007. Check it out here, and then you could modify that code to do what you're looking for. - MMichael Mukalian | Jan 2010 - Dec 2010 MVP SharePoint Services | MCTS: MOSS 2007 Configuration | http://www.mukalian.com/blog
August 10th, 2011 8:09am

HI, This is not possible OOB. YOU can write up a console application to pull out the data or else you can use a sharepoint stuff like you can write a webpart to showthis data. If you need code for this please do let me know. Thanks, Rahul RashuThanks, Rahul Rashu
Free Windows Admin Tool Kit Click here and download it now
August 10th, 2011 8:12am

Hey Rahul, I will really appreciate if you ive me the piece of the code to extract the info. Regards, ShwetaMe
August 10th, 2011 8:51am

Hi, You can create a custom webpart to retrieve all information's from Farm (since you need to loop through all the web apps if your site collections running in number of web applications) The ContentService property of the SPWebService class allows you to get at the web applications running on the server. Then from each one, it’s just a simple matter of enumerating the site collections contained in the Sites collection of the SPWebApplication. static void Main(string[] args) { foreach (SPWebApplication wa in SPWebService.ContentService.WebApplications) { foreach (SPSite sc in wa.Sites) { try { Console.WriteLine("Do something with site at: {0}", sc.Url); } catch (Exception e) { Console.WriteLine("Exception occured: {0}\r\n{1}", e.Message, e.StackTrace); } finally { sc.Dispose(); } } } } And for get the site administrator name, you can use below code: Microsoft.SharePoint.SPUser SiteAuthor = objweb.Author; OR you can also use this link code: http://www.15seconds.com/issue/050512.htm http://blogs.tamtam.nl/duarte/2008/12/09/Sharepoint+How+To+Verify+If+A+User+Is+Site+Administrator.aspxCheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"
Free Windows Admin Tool Kit Click here and download it now
August 10th, 2011 9:34am

just create a console application and implement Sharepoint object module like the following : static void Main(string[] args) { using (SPSite web = new SPSite("http://vaio-pc:25219/")) { SPSiteCollection sites = web.WebApplication.Sites; foreach (SPSite site in sites) { //Current Site Collection Console.WriteLine(string.Format("Site Collection Title {0} admin Name {1} ",site.Url, site.Owner)); foreach (SPWeb w in site.AllWebs) { SPUserCollection admins = w.SiteAdministrators; foreach (SPUser admin in admins) { //Current Web admins Console.WriteLine(string.Format("Site Title {0} Site Admin Name {1}", w.Title, admin.Name)); } } } } Console.ReadLine(); } by this code you can return the owner of each site collection and for example you can also get list of admin for each site in the site collection Regards,
August 10th, 2011 1:12pm

HI Shweta, Here is the code. You need not give any input and you just need to run it only. using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.SharePoint; using Microsoft.SharePoint.Administration; namespace YourNameSpace { class Yourclassname { static void Main(string[] args) { SPFarm farm = SPFarm.Local; SPWebService webService = farm.Services.GetValue<SPWebService>(""); foreach (SPWebApplication webApplication in webService.WebApplications) { foreach (SPSite site in webApplication.Sites) { Console.WriteLine("The Site Owner for the Site Collection " + site.Url + " is" + site.Owner.LoginName +"\n"); using (site) { foreach (SPWeb web in site.AllWebs) { SPUserCollection webAdministrators = web.SiteAdministrators; Console.WriteLine("Now processing the site named " + web.Title + " at the URL " + web.Url); foreach (SPUser user in webAdministrators) { Console.WriteLine(user.LoginName + "\n"); } } } } } Console.ReadLine(); } } I hope this will help you out.Thanks, Rahul Rashu
Free Windows Admin Tool Kit Click here and download it now
August 10th, 2011 3:02pm

Here's the PowerShell script to identify the Site Collection Admins (Owners) for the site collections across the farm. Note it's quick and dirty. [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") $farm = [Microsoft.SharePoint.Administration.SPFarm]::Local $farmWebServices = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]} foreach ($farmWebService in $farmWebServices) { foreach ($webApplication in $farmWebService.WebApplications) { foreach ($site in $webApplication.Sites) { $web = $site.OpenWeb() $scas = "" foreach ($siteAdmin in $web.SiteAdministrators) { $scas = $siteAdmin.LoginName + "; " + $scas } Write-Host "ID:" $site.ID " - URL: " $site.Url " - Owners: " $scas $site.Dispose() } } } Michael Mukalian | Jan 2010 - Dec 2010 MVP SharePoint Services | MCTS: MOSS 2007 Configuration | http://www.mukalian.com/blog
August 10th, 2011 4:54pm

Thanks Michael and rahul.Me
Free Windows Admin Tool Kit Click here and download it now
August 11th, 2011 5:42am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics