I’ve been looking at the -match operator which as I understand returns a Boolean - True / False. I have found that if I use this in some situations it returns the matching item rather than a Boolean. It seems to change behavior if it is used with an object array.
Can someone assist explaining what lies behind this change in behavior.
Example for testing - trying to extract a Version ID stored in a text file
#Path to product details file for testing
$path = ‘C:\temp\productID.txt’
#Load the contents of product into the variable $Details
$Details =get-content -Path $path
#Select the line that contains Versionid (In this format: VersionId : 6cccd490-8861-4118-97f6-3asdjkfua7a4f7)
$Verid=($Details -match “VersionId”)
It seems that I get back $Verid = VersionId : 6cccd490-8861-4118-97f6-3asdjkfua7a4f7 rather than True or false? Thought I should get back a Boolen here??
I can then use the split operator