0

I made a few new Sharepoint groups in one of my test site collections. I can see them in the web interface, I can work with them, so everything seems to be fine. But I cannot use these groups with powershell. This script:

$site = New-Object -Type Microsoft.SharePoint.SPSite -ArgumentList "https://mysite"
$groups = $site.RootWeb.Groups
foreach($i in $groups)
{
write-host $i.name
}

Returns all other groups, but not the new ones. The site was recently restored from a site collection backup and that looks like a break point. Is there any way to fix it?

0

You can replace Groups with SiteGroups.

Try using the below command:

$site = New-Object -Type Microsoft.SharePoint.SPSite -ArgumentList "https://mysite"
$groups = $site.RootWeb.SiteGroups 
foreach($i in $groups)
{
   write-host $i.name
}

It will list all the groups in the site collection

Reference - SPWeb.SiteGroups property

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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