Use Powershell to iterate through all UserProfile properties

dunxd
  • Use Powershell to iterate through all UserProfile properties dunxd

    The following script spits out all UserProfile properties for users on Sharepoint 2007:

    [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server")
    [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.UserProfiles")
    # Function:          Get-UserProfiles
    # Description:       return a UserProfileManager object containing all user profiles
    # Parameters:        SSPName          SSPName    
    #
    Function global:Get-UserProfiles($SSPName)
    {
        $ServerContext = [Microsoft.Office.Server.ServerContext]::GetContext($SSPName);
        $UPManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServerContext);
        return $UPManager.GetEnumerator();
    }
    
    $profiles = Get-UserProfiles("SharedServices");
    $profiles | ForEach-Object { $_.GetEnumerator();}
    

    However, what I want to do is be able to return a table, or csv file of specific values in the profile, e.g. Username, WorkEmail, WorkPhone. I have tried piping the output to |ft Username, WorkEmail, Workphone and | select Username, WorkEmail, WorkPhone but this just returns blanks.

    I feel like I am so close. I don't want to replace the $_.GetEnumerator() call with lots of $_.Item("property") calls and it doesn't feel like I should have to. Any ideas?

Related questions and answers
  • #SPFieldText").each(function() { if(/FieldInternalName=\"Name\"/.test($(this).html())) username = $(this).text(); }); } }); return username.replace(/(^[\s\xA0]+|[\s\xA0]+$)/g, ''); }; One would like to think that this page would always represent the currently logged in user, but sometimes it represents the prior user. Not good. UPDATE 3: I may have come up... us that the authentication method might matter. UPDATE 2: Another piece of info I should have included in the first place: The reason that I'm asking this is that the $().SPServices.SPGetCurrentUser

  • , perform some processing, then spit out a 'token' for consumption by a different connected web part. The token is just the ID in another format. I have the drop-down menu correctly displaying as follows: Connections -> Send Program Entity Token To -> ... -> Get Program Entity ID From -> ... When I select a web part in "Get Program Entity ID From", a dialog appears for me to choose... : WebPart, ITransformableFilterValues { public bool AllowAllValue { get { return true; } } public bool AllowEmptyValue { get { return false; } } public bool

  • in progress, but I am having trouble with the SaveListAsTemplate method which looks like this: Public Shared Function SaveListAsTemplate(ByVal List As SPList, ByVal SaveContent As Boolean..., this is the reason for my post. I cannot get this code to execute from within a console application. Does the SPList.SaveAsTemplate method require a HttpContext? If it does it is not metioned in any of the docs that I have seen. As an aside any other comments on this code gratefully received. EDIT: Exception and Stack Trace System.ArgumentException "Value does not fall within the expected range

  • ;MissedUserProfileProperties> Configure the UserProfile in such a way that it will combine both AD & BCS Please let me know if it can be done? Update - 2 I have configured and populated the required...We want to write a Custom Webservice to pull the User Profile Properties from SharePoint 2007 and should be able to consume the same Webservice in BCS (SharePoint 2010). AIM: 1. Read a User Profile Properties from a Custom Webservice 2. Consume the same Webservice in BCS 3. BCS properties have to be merged with AD properties for the User Profile Properties in SharePoint 2010. Can anybody let

  • I’m trying to write a Http Handler to generate rss xml (based on the CKS code). I want to be able to get the list/library that the end point of the url is referring to. For example if my Url is: http://example.org/pressreleases/pages/rss.xml I want to be able to get the pages library of the 'press releases' web. On a side note if I'm going about this in the wrong way please let me know. Update 1 It may be easier for me to show my code (incase of retardation) public void ProcessRequest(HttpContext context) { try { SPList list

  • I have been developing on SP 2010 for a while now. Mostly I have been working with the Client Object Model. Though I am at a point where I need to read out the UserProfiles from inside SharePoint. I see no other way to do this than to make a custom WCFService and deploy it to SharePoint. So that is what I did. I made an "Empty SharePoint Project" and added the mapped "ISAPI" folder. The code... (UserProfile profile in profileManager) { if (profile["AccountName"] != null) { s += profile["AccountName

  • I am facing a strange issue now. If a page is checked out by someone all others who view this page gets an "Unexpected error" error page. After making some changes to web.config I was able to get the stack trace. Any idea how to solve this issue? This issue started recently after installing an additional language pack but I doubt whether that is the reason for the error. [NullReferenceException: Object reference not set to an instance of an object.] Microsoft.Office.Server.UserProfiles.UserProfileManager.get_m_Site() +101 Microsoft.Office.Server.UserProfiles.UserProfileManager.get

  • Has anyone restored Shared Services Databases from SP1 Server Farm to a new SP2 Server farm? I don't want to lose user related information link My Links etc. I followed the DB attach method as detailed here to restore site content from SP1 to SP2. I am little skeptical about touching the SSP dbs. Can we overwrite the new SSP databases with the old databases and restore all the information? If you have done this in the past, please feel free to share any important pointers. Thanks in advance. Update: I am using the User Replication Engine. It is working fine even for My Links

  • Is there any way in SharePoint 2010 to get the Distinct values of a property across all users? For example, I want a list of all Departments in the Profile Store. In SQL I can do SELECT DISTINCT(PropertyVal) FROM [ProfileDB].[dbo].[UserProfileValue] WHERE PropertyID = 14 but accessing the SQL Database is a big no-no of course, so I wonder if there is something in the object model? Note that accessing the User Information List on an SPSite is not good enough, as only a fraction of all users is in that list. I want to get it directly from the Profile Store. I do not want to loop through

Data information