Tuesday, May 22, 2012

Find a users in SharePoint groups with PowerShell

I've been spending some time investigating the Get-SPUser and Set-SPUser commandlets.  I'll be the first to say that SharePoint 2010 and Powershell is a GREAT way to manage a SharePoint Farm. 

The Problem

I was trying to figure out a simple way to get "Setup Like" information for an existing user, so that we could grant permissions for new users.

It would turn out that this is a pretty simple task. 

get-spuser -identity contoso\bgates -web http://contoso/sites/sitecollection | select groups

{Contoso Owners}

Turns out, contoso\bgates is in the "Contoso Owners" Group (didn't see that one coming).  Well since contoso\sbalmer needs to be setup like contoso\bgates we need to run another line of PowerShell

set-spuser -identity contoso\sbalmer -web http://contoso/sites/sitecollection -group 'Contoso Owner'

No comments: