Forum Discussion
Set-PnPGroup : Group cannot be found
Goal is to create a site collection level SharePoint group with 'Read' permissions, and apply this group to each sub-site. This group should contain several members.
My code is failing on:
Set-PnPGroup -Identity $glbMGRConts -Owner $OwnersGroup
... and says Group cannot be found. Not sure why, the group exists, and this line to set permissions to 'Read' works:
Set-PnPGroupPermissions -Identity $glbMGRConts -AddRole "Read"
#
$varURL = "https://company.sharepoint.com/sites/Sandbox" Connect-PnPOnline -Url $varURL -UseWebLogin #Grab global owners group$OwnersGroup = Get-PnPGroup -AssociatedOwnerGroup #Create name for group$glbMGRConts = "GlobalMGRs" New-PnPGroup -Title $glbMGRConts Add-PnPUserToGroup -LoginName user1@co.com -Identity $glbMGRConts
Add-PnPUserToGroup -LoginName user2@co.com -Identity $glbMGRConts Set-PnPGroupPermissions -Identity $glbMGRConts -AddRole "Read" Set-PnPGroup -Identity $glbMGRConts -Owner $OwnersGroup Function Get-Subsites() { $subwebs= Get-PnPSubWebs -Recurse foreach ($Subweb in $subwebs) { Set-PnPGroupPermissions -Identity $glbMGRConts -web $Subweb -AddRole Read } } Get-SubSites
Chip Cooper Hello.
As you got the object saved to $OwnersGroup Var$OwnersGroup = Get-PnPGroup -AssociatedOwnerGroup
When you set the Owner you have to select the specific attribute that represents the Identity or any unique value inside $OwnersGroup variable.
Set-PnPGroup -Identity $glbMGRConts -Owner $OwnersGroup.Title #Or any other unique identity attribute
Regards
Erick Moreno
- Erick A. Moreno R.Iron Contributor
Chip Cooper Hello.
As you got the object saved to $OwnersGroup Var$OwnersGroup = Get-PnPGroup -AssociatedOwnerGroup
When you set the Owner you have to select the specific attribute that represents the Identity or any unique value inside $OwnersGroup variable.
Set-PnPGroup -Identity $glbMGRConts -Owner $OwnersGroup.Title #Or any other unique identity attribute
Regards
Erick Moreno