I have a CSV file that I need to extract a specific pattern that occurs at the beginning of a line such as:
Line of text:
"555555","A",John"
This works:
Get-Content $CsvFile | Select-String '^"555555"'
This does not:
$idnum = "555555"
Get-Content $CsvFile | Select-String '^"$idnum"'
How do I extract the line when the string is assigned to a variable?
(Get-Content $CsvFile) -match "^`"$idnum". With that said, please take a step back and describe the actual problem you're trying to solve instead of what you perceive as the solution. What do you need the extracted line for?