Editing SharePoint Online User Profiles with PowerShell

You may also like...

22 Responses

  1. Biraj says:

    Every time getting following error
    Cannot find an overload for “PeopleManager” and the argument count: “1”.
    at following line
    $people = New-Object Microsoft.SharePoint.Client.UserProfiles.PeopleManager($context)

  2. Lewis says:

    Ensure you have this installed: SharePoint Online Client Components SDK (http://www.microsoft.com/en-us/download/details.aspx?id=42038)

    Then review: http://sharepoint.stackexchange.com/questions/135140/error-creating-peoplemanager-object-using-csom-in-powershell

    Ensure you’re importing modules from the 16 hive, not 15.

    -Lewis

  3. Chris says:

    Can you add custom properties to SharePoint Online using PowerShell? I thought you could add custom properties using PowerShell in SharePoint 2013, but I haven’t found any code to do it in SPO. I have only found code to update current properties.

  4. Asger says:

    This scripts looks like just the thing we need to accomplish what we need in our sharepoint.

    i have tried executing the script right now, and it executes succesfully, but nothing happens in the About Me Property on my users.

    i have of course changed the script to connect to our own sharepoint online site, but it doesnt change the property of About Me.

    do you have any suggestions?

  5. Lewis says:

    It’s difficult to know what you have of course so I can’t really say where the script might have failed.

    The best thing to do is run each line of the script using the PowerShell ISE (Integrated Scripting Environment) and do some basic debugging.

    I personally would start with the $users variable. Of course if the $Context.Web.SiteUsers call isn’t returning any users, then nothing will get processed by the foreach loop.

    Also add things like Write-Host in to the foreach loop to see if it’s doing anything and which user is being processed or acted on.

  6. Karel says:

    I don’t get all users profiles into the context when I use the admin site. I can export user profiles from sharepoint online when using the main site. But those users don’t exist in de admin site context.

    If I use a different site in my tenant for populating my context I get an access denied on my execute query for all profiles but my own.

    Any way to work around this?

  7. NoOne says:

    Thank you very much!

  8. Karen Cuenco says:

    I have the same dilemma with Karel, I wanted to update a user’s user profile property field. I am a global & sharepoint administrator

  9. Serg says:

    the script doesn’t return information from fields:
    1) “Language Preferences:” | “My Display Languages:”
    2) “Time Zone:”
    Please, Help me. How i can Get and change this Filds from the PowerShell ?

  10. Peter says:

    Hi,
    Everyting in this script runs fine, except actually updating the profile. I get this error when trying to change the email address for a user (not my own):
    Exception calling “ExecuteQuery” with “0” argument(s): “Access denied. You do not have permission to perform this action or access
    this resource.”

    I am Sharepoint Admin, Global Administrator of the tenant…

    Any ideas what permissions I still need to be able to change other users’ properties?

    Thanks

  11. Dave says:

    Thanks for the script, very useful but I have the same issue as Peter, the scripts work perfectly for my account but gives an “Access Denied” error for any other.

  12. Lewis says:

    If you log in to the administration site with that username and password and then go to the user profiles section, do you have permissions to make the changes you want to make manually?

    I’ve just run the script again on my own subscription but I’m logging in with my God account (the onmicrosoft.com account) and have been able to update every profile without issue, so I’m not sure what’s missing for you but it’s clearly a permissions problem related to the account you’re using to do the updates.

  13. Dave says:

    Resolved this by connecting to the admin console as shown in the code above :). I had been connecting to the root sharepoint site.

  14. Mayur Jaiswal says:

    Good Post!
    I have been able to update my user profile properties on a site that i created and i am the admin.
    I have giveen access to a hotmail external user on my site and to a test user that i created for my site.
    I am getting access denied when trying to update their user profile properties.

    Any idea?

  15. Mayur Jaiswal says:

    Thank you Lewis and Dave.

    Everybody.. just take care you use the right url like:
    $site = ‘https://mysite-admin.sharepoint.com/’

    basically the admin one. And you will not get access denied for other user’s profile.

    Have a good day!

  16. Mayur Jaiswal says:

    I need to update profile picture,

    I am using the below code:
    $people.SetSingleValueProfileProperty($userprofile.AccountName, “PictureURL”, “**”

    what value should i give in picture url.

    Do i need to upload the image in a image library and give its url?
    I tried that but that did not work.

  17. Sarang Kulkarni says:

    Please tell me how to reorder the position of user profile properties, like if i have one property in one section and i want to move same property in another section without clicking on move up or move down. Please help seems like this is impossible in the sharepoint online.

  18. Soheil says:

    Sarang Kulkarni, We created a case with MS yesterday for this issue. This is a bug and there are not work around. It took us 3 days to move properties to the correct place holder.

  19. Stuart says:

    Is it possible to change the logon account ID using this script?

  20. Lewis says:

    I very much doubt it. The information is usually populated mainly from your Active Directory. The information you have control over is limited and almost certainly doesn’t cover things like account IDs – this would likely need to be done in AD.

  21. Andy says:

    Did anyone ever find an answer to Serg’s question about Display Languages? I’m trying to get that information from the user profile as well.

  22. Rachel says:

    This is exactly what I am looking for! I’ve been searching forever.
    Can you tell me how I can use this script to update individual information per user from a file? For instance, for each user, I want to put their Hire Date in the About me section.

Discover more from lewisroberts.com

Subscribe now to keep reading and get access to the full archive.

Continue reading