Powershell Tip #4 - Enumerate all the Farm Administrators of SharePoint

by rahul 6/8/2012 1:59:42 PM

In SharePoint, if you want to enumerate all the users in the Farm Administrators group, you can use the following script.

 [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") 
#Provide the URL of SharePoint Central Administration 
$caURL = "http://sp2010:1000"
$CentralAdmin = new-Object Microsoft.SharePoint.SPSite($caURL) 
$RootWeb = $centralAdmin.RootWeb

#Get all the Group Users... in our case it is "Farm Administrators"
$GroupUsers = $RootWeb.SiteGroups["Farm Administrators"] 

clear
 
foreach ($User in $GroupUsers.Users)
{
    $User.LoginName
}
 
$RootWeb.Dispose()
$CentralAdmin.Dispose() 

As a matter of fact, you can change the URL to any Web Application and get any Group information using the code above.

Hope this helps, Wave
Rahul


Quote of the day:
If I knew I was going to live this long, I'd have taken better care of myself. - Mickey Mantle


blog comments powered by Disqus

Rahul Soni

Rahul Soni  Twitter

 LinkedIn

 Facebook

 Email me



Vivek Kumbhar

Vivek Kumbhar  Twitter

 LinkedIn

 Facebook

 Email me


Stack Exchange

profile for Vivek at Server Fault, Q&A for system administrators and IT professionals

profile for Rahul Soni at Stack Overflow, Q&A for professional and enthusiast programmers

Calendar

<<  June 2013  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

View posts in large calendar

All Items
Sign in

Visit Microsoft's Site

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2013, Rahul Soni

Powered by BlogEngine.NET 1.4.5.0