Search

  • Home
  • Screencasts
  • Speaking
  • Downloads
  • Consulting Services
Browsing: / Home / 2012 / October / 16 / How To: Get a list of site owners for all SharePoint sites
Print Email Shortlink

How To: Get a list of site owners for all SharePoint sites

By Yaroslav Pentsarskyy on October 16, 2012 in sharepoint
Tweet

Here is something you may need to verify your users have the access they require: a PowerShell script which will run through all of the site collections and webs and display the list of site owners (people who belong to a Owner group).

Something like this:

Basically you save the code below as a ps1 script and run it in SharePoint Management Shell.
If the output is too long, pipe it to file by using >> c:\output.txt in the command line calling the script.


function IterateSubSites ([Microsoft.SharePoint.SPWeb]$subSite)
{
if ($subSite -ne $null)
{
if($subSite.Webs -ne $null)
{
foreach($subsites in $subSite.Webs)
{
IterateSubSites($subsites)
}
}
}
}

$webApplicationURL = "http://localhost"
$webApp = Get-SPWebApplication $webApplicationURL

foreach($site in $webApp.Sites)
{
foreach($subWeb in $site.AllWebs)
{
Write-Host $subWeb.Url
foreach($group in $subWeb.Groups)
{
if($group.Name -like "*Owners*")
{
Write-Host "Owner(s): "
foreach($user in $group.Users)
{Write-Host $user.Name "; "; }
}
}
if($subWeb.IsRootWeb -ne $true)
{
IterateSubSites($subWeb)
}
$subWeb.Dispose()
}
$site.Dispose()
}

If stuff like this is something you do on a daily basis, you may like my PowerShell for SharePoint book.

Enjoy!

Share this on: Mixx Delicious Digg Facebook Twitter
powershellsite owners security report sharepoint
  • Related Stories
  • Most Popular
  • How to: avoid duplicate load of jQuery, or else!
  • How to: automatically package your SharePoint 2013 branding solutions with design manager
  • How To: improve SharePoint/Office 365 site SEO with page keywords and meta description
  • SharePoint 2013 training for developers
  • How to: setting property bag properties on a web in SharePoint online
  • Enabling geolocation field in your SharePoint 2013 list using an app
  • Enabling geolocation field in your SharePoint 2013 list using an app
  • SharePoint Branding: add a handy function to allow users show/hide quick launch bar
  • Add SharePoint 2010 quick launch toggle on/off feature
  • Modify out of the box and custom SharePoint 2010 workflow forms
  • Creating WCF service in SharePoint 2010
  • SharePoint 2010 Branding: defining new Content Query roll up rendering template
← Previous Next →

Just Released! My SharePoint 2013 Book

My SharePoint books & DVD

Copyright © 2013 sharemuch.com.

Powered by WordPress and News.