I get a strange error when attempting to add a user to a group using sharepoint's powershell:
$spuser = (get-spweb http://server/).ensureuser("DOMAIN\user")
(
Get-SPWeb http://server/site |
Select -ExpandProperty SiteGroups |
Where {$_.Name -EQ "site owners"}
).adduser($spuser)
'Exception calling "AddUser" with "1" argument(s): "<nativehr>0x80070005</nativehr><nativestack></nativestack>"
At line:12 char:1
+ (
+ ~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : UnauthorizedAccessException'
However, this question shows that with the correct permissions (he used site collection admin) this runs correctly. I verified giving myself the same permissions also allowed me to run it. What actual permissions do I need to be able to run this? I'd like to let someone be able to change group memberships for a site without being an admin for the collection
PS: let me know if there's a better way to add users to groups like this, ensureuser() is a strange way to select an spuser object for example (coming from AD powershell)