Thursday, 11 July 2013

SharePoint 2010 - People Picker that is showing the wrong user profile information

Hi again,

introduction to this issue:  Someone has updated information on their MySite but their details have not propagated through to the People Picker, or any list that shows User Information in it.

Why:  This is due to the User Information List, which is used to supply User Information to all the SharePoint functions that use it.  The User Information List only seems to get updated when a user is first introduced to a Site Collection.  Not even a full Profile Sync will fix it. (You can find the User Information List here: http://[rootsite]/_layouts/people.aspx?MembershipGroupId=0).  This issue has been documented before and done very nicely on Gary's blog here: http://blog.falchionconsulting.com/index.php/2011/12/updating-sharepoint-2010-user-information/

The difference is between Gary's blog post and mine, is that his shows how to get a script to iterate through every Web Application and update specific fields.  Where as I will be showing how to look for a specific field & update it manually.

HOW TO FIX USING POWERSHELL

First get the User ID of the person who is having the issue:

$user = Get-SPUser -Identity 'domain\username' -Web http://sharepointserver
$user.id

Then you need to navigate to the Users details in the User Information List using their user ID you just found.  This code will list all the fields for that user appearing in the User Information List

$web = Get-SPWeb http://SharePointServer
$list = $web.Lists["User Information List"]
$item = $list.GetItemById($user.id)
$list.fields | % {Write-Host "$($_.InternalName) = $($item[$_.InternalName])"}

Now you should have found the field causing the issue, so you can update it like this:

$item["FieldName"] = "  "
$item.SystemUpdate()

Done!  Because this is a manual way of searching for the right fields to update, you will need to do this for every Web Application.

8 comments:

  1. I tried this and it didn't update anything.

    ReplyDelete
  2. Hi Tony,
    No good. I will try and help you with a few tips below, but if they don't work will require some more detail.

    A few things to check:
    Did you List all the fields again for that user after you ran the SystemUpdate to ensure that the field was updated successfully?
    Where is the outdated profile information appearing on your site?
    Is it only happening on one Web Application?
    Have you ran the Update on every Web Application that you notice the issue on?

    Let me know how you go.

    Thanks,
    Brett

    ReplyDelete
  3. Hi Brett, I know this is a fairly old post, but my company just moved sharepoint to a completely different domain, and I've experienced some residual effects in people picker because of it. The script worked find up to the $item["FieldName"] = " " step. I figured there was something I was missing, and tried it different ways....like this $item[Email]="Jagdish.Kapure@mycompany.com" but get the : Missing or invalid array index expression.
    + CategoryInfo : ParserError: ([:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingArrayIndexExpression

    And like this - $item["Email"]="Jagdish.Kapure@mycompany.com"
    [ : Unable to index into an object of type Microsoft.SharePoint.SPListItem.
    At line:1 char:7
    + $item[ <<<< "Email"]="Jagdish.Kapure@mycompany.com"
    + CategoryInfo : InvalidOperation: (Email:String) [], RuntimeException
    + FullyQualifiedErrorId : CannotIndex

    Can you see what I'm doing wrong? Thanks - Rick

    ReplyDelete
    Replies
    1. Hi Rick, I can run a few tests in a day or teo to try and get the same errors as you and see what's happening.

      For the moment, my guess is that when you set the $item variable using the $user.id it hasn't actually grabbed that user profile.

      Double check $item contains a list of all the user properties by just typing $item in its own. It should list like 20 or so user properties from memory including email. If it doesn't, try setting the $item variable by typing the user is number manually .

      Hope that helps, Let me know how you go.

      Delete
  4. Thanks for responding Brett. Yeah, the $item is set fine...it displays all that stuff...ParentList, UID, Web etc. etc.

    ReplyDelete
  5. This worked for the root site in the root site collection in my webapp, but not the other site collections. Can you make any suggestions. I changed my display name as a test to Minnie Mouse and it is showing up everywhere in SharePoint. I changed it back to what it should be and it won't change back. Even the people picker is displaying Minnie Mouse. A tad embarrassing.

    ReplyDelete
    Replies
    1. If I try to access a different site collection by url, it will not accept the userid I obtained for the root site collection. If I ask for the userid in another site collection it comes back as 1, and then errors out when I use 1 as the userid.

      Delete
    2. Hi Carollyn, haha oh very embarrassing! Your userID will be different for every site collection. So you will need to get the correct User ID for each site collection E.g.:

      ##Run the first two lines of code on each site collection:
      $user = Get-SPUser -Identity 'domain\brett' -Web http://root/sitecollection1
      $user.id

      $user = Get-SPUser -Identity 'domain\brett' -Web http://root/sitecollection2
      $user.id


      Delete