locked
Arrays and assignments RRS feed

  • Question

  • Hi Experts,

    I have a manually assigned array like this and all is working

    manual example

    $array = @("Delia Dennis", "Johanna Lorenz","Martha Daniels", "Myrna Casey" ) 

    and when i select the 1st value of the array I get the proper results--->

    $array[0]
    Delia Dennis

    Now when I attempt to assign the $array via this pipe command , I'm  get not the right results

    $array  =Get-MsolUser | Select DisplayName

    $a[0]

    DisplayName 
    ----------- 
    Delia Dennis

    Issue----I need to get the above "Display name" (title) removed and only see the value "Delia Dennis"...Similar to the manual example...

    Why---I need to do more processing of the array  via ForEach  and the non-manual assignment the "Display Name" title gets into the way of selecting individual elements of the array.

    thank in advance

    magellan99

    Friday, May 3, 2019 11:03 PM

All replies

  • First start by learning basic PowerShell. You can never learn this technology by guessing.

    Start here: Microsoft Virtual   Academy - Getting Started with Microsoft PowerShell

    This will teach you how to use these things that you are guessing at.  Remember that PowerShell and Net are both object programming systems.


    \_(ツ)_/


    • Edited by jrv Friday, May 3, 2019 11:29 PM
    Friday, May 3, 2019 11:29 PM
  • $a[0].DisplayName 
    Friday, May 3, 2019 11:29 PM
  • $array  = Get-MsolUser | Select -Expand DisplayName

    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Saturday, May 4, 2019 1:21 AM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,

    Lee


    Just do it.

    Friday, May 31, 2019 3:19 AM