September 28, 2022

Samir Daoudi's Technical Blog

SharePoint, Office 365, C#, .Net, SQL Server News, Tips, Ebooks, Events, Webinars ….etc

List of SharePoint sites with list of users in %owner% Groups

harePoint") > $null harePoint harePoint foreach ($websvc in $websvcs) foreach ($site in $webapp ites) write-host $site foreach ($web in $site foreach ($group in $web roups) $G = $group if ($G -match "owner") foreach ($user in $group sers)

[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”) > $null

$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local
$websvcs = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]}
$webapps = @()

foreach ($websvc in $websvcs)
{
foreach ($webapp in $websvc.WebApplications)
{
foreach ($site in $webapp.Sites)
{
write-host $site.URL
foreach ($web in $site.AllWebs)
{
write-host $web.URL
foreach ($group in $web.Groups)
{
$G = $group.Name
if ($G -match “owner”)
{
write-host ”  –>” $G
foreach ($user in $group.Users)
{
write-host ”     –>” $user.Name
write-host “”
}
}
}
}
}

}
}
GO

Leave a comment

You may have missed

Show Buttons
Hide Buttons

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

%d bloggers like this: