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,
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