Powershell question: I have an array $myArray that contains the following values:
$myArray[0]:smith,server1,1/1/2015 10:00:00
$myArray[1]:smithpeter,server1,1/1/2015 10:00:00
I'd like to find out if $myArray already contains the value "smith" anywhere, but I do not want to include "smith*" (e.g. smithpeter) in the results.
If I try
[regex]$regex="smith"
$myArray -match $regex
it returns both records (smith and smithpeter) --> correct, but not what I want.
If I try
[regex]$regex="smith,"
$myArray -match $regex
I am getting no results.
I can't find any proper answers online. I believe the fact that I have a comma (",") in the string seems to be causing some issues with the query.
Thanks for any input.