Question: Why this code doesn’t display ‘Found’ ?
Not working
Answer :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# Answer: # Solution 1 if ($computer -match 'DELL') # Solution 2 if ($computer -like '*DELL*') # Explanation: The operator -contains works on arrays (not strings). $computer = 'PC-DELL-123', 'PC-DELL-456' if ($computer -contains 'PC-DELL-123') { 'Found' } else { 'Not Found' } |