locked
Updating User Information List "Department" Property 'department' cannot be found on this object; make sure it exists and is settable. RRS feed

  • Question

  • I understand that the user information list and the profile import list has no relationship and is not synched by default. Unfortunately I have a few inconsistencies after doing user migrations with some botched accounts. I'm trying to update the user information list /_catalogs/users/simple.aspx for a few users but some properties are not found.

     

    For example I can update the "work e-mail" property by doing below. However when I try to update the "Department" it complains that property cannot be found.

     

    PS H:\> $site = New-Object -TypeName Microsoft.SharePoint.SPSite -ArgumentList h
    ttp://inside.simplexity.com
    PS H:\> $user = $site.RootWeb.SiteUsers["corp\jsmith"]
    PS H:\> $user.Name = "John Smith"
    PS H:\> $user.Update()
    PS H:\> $user.email = jsmith@company.com
    PS H:\> $user.Update()

    However updating the department complains.
    PS H:\> $user.department = "HR"
    Property 'department' cannot be found on this object; make sure it exists and is settable.
    At line:1 char:7
    + $user. <<<< department = "HR"
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : PropertyAssignmentException


    James Chong MCITP | EA | EMA; MCSE | M+, S+ Security+, Project+, ITIL msexchangetips.blogspot.com
    • Moved by Mike Walsh FIN Tuesday, June 28, 2011 7:37 PM hardly a general q (From:SharePoint - General Question and Answers and Discussion (pre-SharePoint 2010))
    Tuesday, June 28, 2011 1:51 PM

Answers

  • Hi Jamestechman,

     

    Thanks for your post.

    First, if you use the code below to get the User object, what you get is not the item in the “User Information List”, but is the SPUser object.

    $user = $site.RootWeb.SiteUsers["corp\jsmith"]

    There is not a “Department” Property for the SPUser Object, instead, there is a “Email” Property. You can get more information about this class:

    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spuser_members.aspx

     

    Second, you can get the User item in the “User Information List” at first, and then update its properties as following:

    $site=[Microsoft.SharePoint.SPSite]("http://servername:port")

    $web=$site.OpenWeb()

    $list=$web.Lists["User Information List"]

    $item=$list.GetItemById(10)

    $item["Department"]="new department"

    $item.Update()

     

     

    Thanks,

    Wayne Fan

    TechNet Subscriber Support in forum

    If you have any feedback on our support, please contact  tnmff@microsoft.com.

    • Marked as answer by Jamestechman Wednesday, June 29, 2011 3:26 PM
    Wednesday, June 29, 2011 2:01 AM

All replies

  • Hi Jamestechman,

     

    Thanks for your post.

    First, if you use the code below to get the User object, what you get is not the item in the “User Information List”, but is the SPUser object.

    $user = $site.RootWeb.SiteUsers["corp\jsmith"]

    There is not a “Department” Property for the SPUser Object, instead, there is a “Email” Property. You can get more information about this class:

    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spuser_members.aspx

     

    Second, you can get the User item in the “User Information List” at first, and then update its properties as following:

    $site=[Microsoft.SharePoint.SPSite]("http://servername:port")

    $web=$site.OpenWeb()

    $list=$web.Lists["User Information List"]

    $item=$list.GetItemById(10)

    $item["Department"]="new department"

    $item.Update()

     

     

    Thanks,

    Wayne Fan

    TechNet Subscriber Support in forum

    If you have any feedback on our support, please contact  tnmff@microsoft.com.

    • Marked as answer by Jamestechman Wednesday, June 29, 2011 3:26 PM
    Wednesday, June 29, 2011 2:01 AM
  • Thanks for the link, got confused because when updating the $user.email it added the email address into the user information list so thought the spuser type had ability to edit this list but understand there is no field for the spuserobject. Thanks again.


    James Chong MCITP | EA | EMA; MCSE | M+, S+ Security+, Project+, ITIL msexchangetips.blogspot.com
    Wednesday, June 29, 2011 3:26 PM