Thursday, May 17, 2012

Update Site collection user without the User Profile Service

Updating Site Collection Users - Without a User Profile Service

Recently I ran into users, who were added to a Site Collection, but found they had incorrect information in Active Directory at the time of addition.  Active Directory had been updated since, but the Site Collection User had not been.

Problem - Update a Site Collection User that had incorrect information, listed in Active Directory, when added to the Site Collection.

It was a simple mistake where a Display Name had been was listed incorrectly. 

The Script

Here is an extremely complex PowerShell command to fix this issue:

Set-SPUser -Identity 'contoso\sbalmer' -DisplayName 'Balmer, Steve' -Web http://contoso/sites/sitecollection

The basics of this line of extremely complex powershell is broken down to the following:

Commandlet - Set-SPUser
Identity - 'Domain\UserName'
DisplayName 'LastName, FirstName'
Web - The site collection where the user needs to be updated.

The Next Question

This made me ask another question:  How do we refresh all attributes from Active Directory for a User? 

I found this to be even more complex than the first line of PowerShell from above. 

Set-SPUser -Identity 'contoso\sbalmer' -SyncFromAd -Web http://contoso/sites/sitecollection

This will simply update the user from Active Directory, for the listed site collection. 

This will also resolve the issue if a user has the same Domain Account ID as a former employee.  This is probably rare, unless the site was migrated from previous environments from years past. 


No comments: