System.Object[]

Tagged: 

This topic contains 1 reply, has 1 voice, and was last updated by Profile photo of Tony Antony Tony Antony 2 months, 1 week ago.

  • Author
    Posts
  • #61917
    Profile photo of Tony Antony
    Tony Antony
    Participant

    I have a function that to find the user index as below.

    function Find_User_Index ([string]$email)
    {
        $E = ($Read_INI | Select-String -AllMatches "$email" -SimpleMatch)
        $E.ToString().Trim("=$email")
    }

    This works fine when I enter
    nbetz@company.com
    tantony@company.com

    But, when I type in cconner@company.com, I get this System.Object[]

  • #61918
    Profile photo of Tony Antony
    Tony Antony
    Participant

    I found the problem. cconner is the admin and there was 2 cconner@company.com values in the text file. No one else have duplicates.
    I added

    | Select-Object -First 1

    , and it's working now.

    function Find_User_Index ([string]$email)
    {
        $E = ($Read_INI | Select-String -AllMatches "$email" -SimpleMatch) | Select-Object -First 1
        $E.ToString().Trim("=$email")
    }

    Please close this post.

You must be logged in to reply to this topic.