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
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.