Hi,
Create the file c:\temp\temp.txt with the single line "cd foo" (without the quotes).
Then try this:
$dirs=Get-Content c:\temp\temp.txt | Where {$_ -match "^cd "}
$dirs[0] (equals "c")
Now add the line "cd foo" to the file and repeat the above.
Now $dirs[0] (equals "cd foo")
It doesn't matter if I initialize $dirs as $dirs=@().
So, how do I force an array context for $dirs, even when Get-Content only returns a single line? I need $dirs[0] to always return the full line from the file, whether the file contains 1 or >1 matches.
Thanks...