A while back I asked about Batch Script Redirection Syntax and received a nice answer. I've utilized the parenthesis () method more often to echo in batch scripts and redirect to files, etc.
I've run into an odd issue where it appears the word Where is not be able to be echo'd as that word literally and it seems it's interpreted as the Where command being invoked instead.
To keep this example simple, I've dumbed down the script logic to a much simpler version, but the PowerShell logic being echo'd could be much more complex than this.
Script Example
@ECHO ON
(
ECHO [System.IO.DriveInfo]::GetDrives() ^| Where {$_.Name -like "C:\"}
)>> Outfile.txt
PAUSE
Error
INFO: Could not find files for the given pattern(s).
What I've done
I troubleshot this a little and did some quick research and couldn't find a simple answer. Since I have not asked many questions on SuperUser, I figured this would be a good one potentially.
One thing in particular I tried was setting a variable as a string value of Where (i.e. SET w=Where) and then in the parenthesized echo commands I referenced that variable (i.e. %w%) in place of the word Where but the result is still the same error.
I also played around a little with SETLOCAL ENABLEDELAYEDEXPANSION but it made no difference.
@ECHO ON
SET w=Where
(
ECHO [System.IO.DriveInfo]::GetDrives() ^| %w% {$_.Name -like "C:\"}
)>> Outfile.txt
PAUSE
The Workaround
I have simply not been using the parenthesized method for echoing the word "Where" and I have just been utilizing the appended >> redirect to the file method on each echo'd line individually where "where" is involved. No big deal for this small example but a bigger deal for a larger script.
@ECHO ON
ECHO [System.IO.DriveInfo]::GetDrives() ^| Where {$_.Name -like "C:\"}>> Outfile.txt
PAUSE
Correlated Questions
Hmmmmm......
What is causing this and what exactly is happening when this occurs?
Is there a way to allow the word (or string) "
Where" to be used without the issue?

whereis not completely irrelevant: it waswhere.exethat generated the error messageINFO: Could not find .... In other words, because of the questioner's syntax,wherewas taken as a command, rather than a clause. – AFH Oct 23 '17 at 13:16&after the). But some how the escaped|is allowingWhereto be interpreted as a command. – dbenham Oct 23 '17 at 15:01). Unless you are a batch geek like me, that is all you need worry about. The other obscure issue (a newly discovered quirk) is you cannot escape a special character token like|immediately following closure of a parenthesized block. That shouldn't be an issue because I'm not aware of any valid syntax that uses an escaped token after closure. But the behavior violates our current understanding of batch parsing rules. (Continued in next comment) – dbenham Dec 25 '17 at 14:28