I am using this code but I would like to view in a table and export as a CSV but all my attempts have failed. Where does the code go?

$siteUrl = "URL" 
$site = Get-SPSite $siteUrl
$groups = $site.RootWeb.sitegroups
foreach ($grp in $groups) {"Group: " + $grp.name; foreach ($user in $grp.users) {"  User: " + $user.name} }

1 Answer 1


What about trying this?

SPGroupCollection $groups = $site.SiteGroups;

instead of

$groups = $site.RootWeb.sitegroups 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.