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
$site.RootWeb.SiteAdministrators
$groups = $site.RootWeb.sitegroups
foreach ($grp in $groups) {"Group: " + $grp.name; foreach ($user in $grp.users) {" User: " + $user.name} }