How can I get values of properties from powershell

I am trying to put together a powershell script that, for a given user, displays all of the user profile property information.
I have seen several blogs which show how to get the names of all the properties.
I thought that displaying the value of the property would be simple. So far, I am missing something.
function display-UserProfile
Param(
 [string]$SCURL,
 [string]$accountName
## $SCURL is a string that contains the URL path to a site collection
## $accountName is a string that contains the account name for which we need to get the profile property information
##Get the user profile property information by account name using SharePoint 2010 web service in powershell
$uri=$SCURL + "/_vti_bin/UserProfileService.asmx?wsdl"
## Web Service Reference -
http://Site/_vti_bin/UserProfileService.asmx
$userProfileWebServiceReference = New-WebServiceProxy -Uri $uri -UseDefaultCredential
$propertyData=$userProfileWebServiceReference.GetUserProfileByName($accountName)
Write-Host -ForegroundColor Magenta "Getting the user profile property information by account name"
foreach($property in $propertyData)
 Write-Host -ForegroundColor Yellow $property.Name, $property.Value
When I run this, I don't get anything. I tried using "Values" but that gave me nothing for some properties and a long "path" for others
Surely the property's current setting is in the object - I just am not certain how to get it to display.
Can anyone show me what I am missing?

Hi,
Please try to use this:
$property.Values[0].Value
The following C# code snippet for your reference:
public void FormEvents_Loading(object sender, LoadingEventArgs e) {
XPathNavigator myRoot = MainDataSource.CreateNavigator();
ProfileService.UserProfileService profileService = new ProfileService.UserProfileService();
ProfileService.UseDefaultCredentials = true;
ProfileService.PropertyData[] userProps = null;
try {
// Passing null to this method causes the profile of the current user to be returned.
userProps = profileService.GetUserProfileByName(null);
catch { }
if (userProps == null || userProps.Length == 0) {
return;
for (int i = 0; i < userProps.Length; i++) {
XPathNavigator node = null;
switch (userProps[i].Name.ToLower()) {
// these property names can be obtained by reviewing the user profile properties in the MOSS SSP.
case "preferredname":
node = myRoot.SelectSingleNode("/my:myFields/my:userName", NamespaceManager);
break;
case "accountname":
node = myRoot.SelectSingleNode("/my:myFields/my:userAccount", NamespaceManager);
break;
case "workemail":
node = myRoot.SelectSingleNode("/my:myFields/my:userEmail", NamespaceManager);
break;
case "workphone":
node = myRoot.SelectSingleNode("/my:myFields/my:userPhone", NamespaceManager);
break;
default:
continue;
ProfileService.ValueData[] values = userProps[i].Values;
if (values.Length > 0) {
if (node != null && string.IsNullOrEmpty(node.Value)) {
node.SetValue(values[0].Value.ToString());
More information:
http://blogs.msdn.com/b/infopath/archive/2007/03/07/get-the-user-profile-through-moss-web-services.aspx
Best Regards
Dennis Guo
TechNet Community Support

Similar Messages

  • How can I get values from listbox?

    Hi all,
    I need to get price values from Price List (Inventory -> Item Master Data screen). It's important to get values from field 'Price' BEFORE item will be added/updated.
    How can I get values from Pricelist listbox?
    Thanks for any suggestions or short sample code.
    Best regards,
    Andy

    Hi Andy
    Here is som sample code that will get the description of the price list and also the price that is displaying at the time. The item master must be open for this snippet of code
      Public Sub GetItemPriceFromOpenWindow()
            'this is assuming item master is open
            Dim oEdit As SAPbouiCOM.EditText
            oEdit = SBO_Application.Forms.GetForm("150", 1).Items.Item("34").Specific
            SBO_Application.MessageBox(oEdit.Value)
            Dim oCmb As SAPbouiCOM.ComboBox
            oCmb = SBO_Application.Forms.GetForm("150", 1).Items.Item("24").Specific
            SBO_Application.MessageBox(oCmb.Selected.Description)
        End Sub
    Hope it helps

  • How can i get value from tilelist?

    I have created checkbox in itemRenderer that use for TileList
    How can i get value (checked) from checkbox?

    "Marsza" <[email protected]> wrote in
    message
    news:g6r6vj$di0$[email protected]..
    > Help me please....... T_T
    Could you rephrase the question?

  • How can I get an itunes movie from macbook to apple tv via airplay, how can I get an itunes movie from macbook to apple tv via airplay

    how can I get an itunes movie from macbook to apple tv via airplay?

    You don't use Airplay.  You set up Home Sharing on both and under the Computers section of AppleTV you'll then find it under Movies (or Rentals if rented), assuming it's in a compatible format.
    AC

  • How can I get the "text" field from the actionEvent.getSource() ?

    I have some sample code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.ArrayList;
    public class JFrameTester{
         public static void main( String[] args ) {
              JFrame f = new JFrame("JFrame");
              f.setSize( 500, 500 );
              ArrayList < JButton > buttonsArr = new ArrayList < JButton > ();
              buttonsArr.add( new JButton( "first" ) );
              buttonsArr.add( new JButton( "second" ) );
              buttonsArr.add( new JButton( "third" ) );
              MyListener myListener = new MyListener();
              ( (JButton) buttonsArr.get( 0 ) ).addActionListener( myListener );
              ( (JButton) buttonsArr.get( 1 ) ).addActionListener( myListener );
              ( (JButton) buttonsArr.get( 2 ) ).addActionListener( myListener );
              JPanel panel = new JPanel();
              panel.add( buttonsArr.get( 0 ) );
              panel.add( buttonsArr.get( 1 ) );
              panel.add( buttonsArr.get( 2 ) );
              f.getContentPane().add( BorderLayout.CENTER, panel );
              f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              f.setVisible( true );
         public static class MyListener  implements ActionListener{
              public MyListener() {}
              public void actionPerformed( ActionEvent e ) {
                   System.out.println( "hi!! " + e.getSource() );
                   // I need to know a title of the button (which was clicked)...
    }The output of the code is something like this:
    hi! javax.swing.JButton[,140,5,60x25,alignmentX=0.0,alignmentY=0.5,
    border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@1ebcda2d,
    flags=296,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,
    disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=2,left=14,bottom=2,
    right=14],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=true,
    rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=first,defaultCapable=true]
    I need this: "first" (from this part: "text=first" of the output above).
    Does anyone know how can I get the "text" field from the e.getSource() ?

    System.out.println( "hi!! " + ( (JButton) e.getSource() ).getText() );I think the problem is solved..If your need is to know the text of the button, yes.
    In a real-world application, no.
    In a RW application, a typical need is merely to know the "logical role" of the button (i.e., the button that validates the form, regardless of whether its text is "OK" or "Save", "Go",...). Text tends to vary much more than the structure of the UI over time.
    In this case you can get the source's name (+getName()+), which will be the name that you've set to the button at UI construction time. Or you can compare the source for equality with either button ( +if evt.getSource()==okButton) {...}+ ).
    All in all, I think the best solution is: don't use the same ActionListener for more than one action (+i.e.+ don't add the same ActionListener to all your buttons, which leads to a big if-then-else series in your actionPerformed() ).
    Eventually, if you're listening to a single button's actions, whose text change over time (e.g. "pause"/"resume" in a VCR bar), I still think it's a bad idea to rely on the text of the button - instead, this text corresponds to a logical state (resp. playing/paused), it is more maintainable to base your logic on the state - which is more resilient to the evolutions of the UI (e.g. if you happen to use 2 toggle buttons instead of one single play/pause button).

  • How can i get the max rpm from cpu fan??

    how can i get the max rpm from my cpu cooler regarding that i don't have a speed controller attached to the cpu fan ,,, ??  please make things clear for me
    thanks

    if you have not reduced it by using a speed controller either hardware or software or by the 7v mod its already going as fast as it will at 12 v dc you cannot speed it up only slow it down
    need more air get a different cooler/fan

  • How can I get the edited pictures from the thumbnails to full size?

    I upgraded to iPhoto 11, the thumbnail photos show my previous edits, but when I click on the photo to make it bigger, it reverts back to the unedited, original picture.  How can I get the edited pictures from the thumbnails to full size?

    Verify you are using iPhoto11 ver 9.5
    if not run the >Software update or check your apps folder and make sure the correct iPhoto is launched,  not an older ver.

  • How can I get the XML structure from a flat structure?

    Hi all,
    in my XI SP 12 I use a JMS adapter to read information using the WebSphereMQ transport protocol.
    The structure that I receive have this format:
    <Name_A.KeyFieldValue><Name_A.fieldName_A1_Value>...<Name_A.fieldName_AN_Value>
    <NumberRecordType_B><NumberRecordType_c>
    <Name_B.KeyFieldValue><Name_B.fieldName_B1_Value>...<Name_B.fieldName_BN_Value>
    <Name_B.KeyFieldValue><Name_B.fieldName_B1_Value>...<Name_B.fieldName_BN_Value>
    <Name_C.KeyFieldValue><Name_C.fieldName_C1_Value>...<Name_C.fieldName_CN_Value>
    <Name_C.KeyFieldValue><Name_C.fieldName_C1_Value>...<Name_C.fieldName_CN_Value>
    the problem is that in this structure each line is not separated by a carriage return or a comma, I have all the information in a single line:
    <Name_A.KeyFieldValue><Name_A.fieldName_A1_Value>...<Name_A.fieldName_AN_Value><NumberRecordType_B><NumberRecordType_c><Name_B.KeyFieldValue><Name_B.fieldName_B1_Value>...<Name_B.fieldName_BN_Value>...<Name_B.KeyFieldValue><Name_B.fieldName_B1_Value>...<Name_B.fieldName_BN_Value><Name_C.KeyFieldValue><Name_C.fieldName_C1_Value>...<Name_C.fieldName_CN_Value>...<Name_C.KeyFieldValue><Name_C.fieldName_C1_Value>...<Name_C.fieldName_CN_Value>
    and the customer don't want to insert a line separator.
    Then, the question is:
    How can I get the XML structure from this structure?
    If possible, I don't want to develop new Module and add it in the JMS Module Sequence.
    PS I have already read the article "How to Use the Content Conversion Module with the XI 3 J2EE JMS Adapter.pdf" and it doesn't seem to help me.
    Best Regards,
    Paolo

    To get context parameters from your web.xml file you can simply get the ActionServlet object from an implementing action object class. In the perform (or execute) method make the following call.
    ServletContext context = getServlet().getServletContext();
    String tempContextVar =
    context.getInitParameter("<your context param >");

  • How can i get the source code from java concurrent program in R12

    Hi 2 all,
    How can i get the source code from java concurrent program in R12? like , "AP Turnover Report" is java concurrent program, i need to get its source code to know its logic. how can i get its source code not the XML template?
    Regards,
    Zulqarnain

    user570667 wrote:
    Hi 2 all,
    How can i get the source code from java concurrent program in R12? like , "AP Turnover Report" is java concurrent program, i need to get its source code to know its logic. how can i get its source code not the XML template?
    Regards,
    ZulqarnainDid you see old threads for similar topic/discussion? -- https://forums.oracle.com/forums/search.jspa?threadID=&q=Java+AND+Concurrent+AND+Source+AND+Code&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    Thanks,
    Hussein

  • How can I get audio to play from my TV when using hdmi cable?  Video looks great, just no sound.

    How can I get audio to play from my TV when using hdmi cable?  Video looks great, just no sound.
    I've tried plugging the hdmi into the TV directly and the receiver.
    I get video every time.  HBO to Go , Xfinity, ABC, Youtube, etc...
    just no audio.  Any suggestions? 
    I've tried starting the apps then plugging in the hdmi cable.
    I never tried this before I upgraded to IOS 5.

    Claudiamil-
    I had not tried it with mine since upgrading to iOS 5, so I just did.  I'm using a small Vizio HDTV.  I did not try YouTube, but did try several videos and musical numbers.  In all cases there was sound, including stereo when the source had it.
    I assume you are getting sound from the iPad when the adapter is not connected, so the volume is not turned down.  Dah*veed's suggestion to reset may be what you need.
    Fred

  • When creating a book how can I get all the photos from an album to show up in the order they were in the album?

    When creating a book in iphoto, how can I get all the photos from the album I want to use to show up in the order that they are in the album?  When I tried to use the option to add my own photos instead of having the program "flow" them, they showed up all mixed up.

    iPhoto puts them in the book in chronological order.  So to get your photos from an album into an iPhoto book in the same order you will need to use the Photos ➙ Batch Change ➙ Date menu option and set them all to the same date with a 1 minute time difference between each. 
    OT

  • How can i get an duplicate invoice from my MacBook which I bought in an independent Apple retail store

    how can i get a duplicate invoice from my MacBook which I bought in an independent Apple retail store in poland

    Call the store & ask the sales staff to send you one if you are no longer in Poland.  If you are still there, what is stopping you from visiting the store? 

  • My hard drive crashed how can i get my old music from my itune account

    my hard drive crashed how can i get my old music from my itune account

    If you have the media on an iDevice then you should be able to get most of your non-iTunes purchases back as well. See this post from forum regular Zevoneer for options.
    tt2

  • My computer broke down and now i bought a new  Mac,  how can i get my music back from iTunes??

    my computer broke down and now i bought a new  Mac,  how can i get my music back from iTunes??

    Unless you subscribe to iTunes Match , Apple does not keep a backup of your iTunes library.  Even then it is not the library as it exists on your computer, but some version of the media, and only media files, not playlists.  Even then not all media are definitely available since anything removed from the iTunes Store since you purchased it is not available for re-download.
    FAQ: Why iTunes Match Can Not Be Used as a Backup - https://discussions.apple.com/docs/DOC-4112
    Using Match as a backup for iTunes - https://discussions.apple.com/message/17039436#17039436
    In your case it sounds like you will have to obtain non iTunes purchases from their original source or a backup you may have made at some time in the past.

  • How can i get all the records from three tables(not common records)

    Hi
    I have four base tables at R/3-Side. And i need to extract them from R/3-Side.
    And i dont have any standard extractor for these tables .
    If i create a 'View' on top of these tables. Then it will give only commom records among the three tables.
    But i want all the records from three base tables (not only common).
    So how can i get the all records from three tables. please let me know
    kumar

    You can create separate 3 datasources for three tables and extract data to BW. There you can implement business login to build relation between this data.

Maybe you are looking for

  • HT1495 How can I transfer all my stuff from my old i-pad to my new one ?

    How can I transfer all my stuff from from my old i-pad 1 to my i-pad 2 ?

  • I need to get an i7 late2011 logic board

    My macbook pro 13" is having a fault with the logic board so I need to replace it and I wanna know where I can get a cheap and durable one. it's a 2.8GHz. Thanks.

  • Problem to install Flash Player.

    Mi problema surgió al actualizar el Flash Player, lo que sucedió es que no me funcionaban algunos reproductores de internet, entonces trate de desinstalar manualmente y volver a instalar, pero lo que pasa es que cada vez que abro el archivo de instal

  • My music wont update when i sync

    Hi, I'm having a weird problem where I change the songs on my iphone playlist, but when i sync my iphone, the changes don't take effect.  I have a bunch of albums for one specific artist that i'd like to trim down to 1 or 2, so I deleted most of the

  • Canon LBP 660 driver for solaris 9

    Hello there, I just install solaris 9 in an x86 machine but my laser printer canon LBP 660 is no more recognised. My printer uses parallele port. Someone can help me to solve this problem, so I could print please? Amani