4 comments

  1. I would like to compare the account name in the site collection user profile table with the account name in the farm level user profile and a) get a list of all the site collection user profiles that differ from the farm and b) have an option to update the site collection information.

    Are you aware of any articles that discuss doing something like this in powershell?
    Thank you

    1. Tricky questions. When you iterate over the profiles you can export that information to the file system and import it to excel. For the Site Collection thing you can create another PowerShell script that gets all items of the so called “User Information List”.
      You can compare the user information using Excel.

      For updating the information you should check out the following blog post: Updating SharePoint User Information

  2. Hi, DEV Machine – just tried to run this via SharePoint 2010 Management Shell. After leaving it for a while, I get no error message, it just looks like it’s sitting there doing nothing

    When checking UPS via CA, I am still seeing the same number of user profiles (5000+)

    # Load required Assemblies for SharePoint Server and User Profile

    [System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.Office.Server”)
    [System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.Office.Server.UserProfiles”)

    # Central Adminstration URL or any Web Application
    $url = “http://yourserver:11237″
    # Create a new Context Object
    $contextWeb = New-Object Microsoft.SharePoint.SPSite(“http://yourserver);

    # Get the right Service Context
    $ServerContext = [Microsoft.Office.Server.ServerContext]::GetContext($contextWeb);

    # create a new connection to the UserProfileManager
    $UserProfileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServerContext);

    # Ger all User Profiles
    $Profiles = $UserProfileManager.GetEnumerator();

    # Loop through user profile
    foreach ($oUser in $Profiles ) {
    # Remove Profile
    $UserProfileManager.RemoveUserProfile($oUser.item(“AccountName”));
    }

    1. Hi Cliff,

      thank you for asking but unfortunately I never had such big amount of users to deal with. What you might could do is to add the following lines inside the foreach look:
      Write-Host $oUser.item(“AccountName”);
      # Remove Profile
      $UserProfileManager.RemoveUserProfile($oUser.item(“AccountName”));

      This should then output the progress of the deletion. Another issue here is that you might have to request the users in batches.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">