The following line works fine in powershell 2.0.
servermanagercmd.exe -query | Select-String "Application Server" -Context 0,13
But when I incorporate it into my batch file it only attempts to run the first part and then returns an error when it gets to Select-String. Does anyone know how to make sure that it reads the whole line? I tried the ^ before my pipe, but it still won't recognize the full line.
You're trying to use one of PowerShell's built-in commands from cmd.exe and that won't work. However you could execute PowerShell from a .bat file, passing in the command you want to execute:
powershell.exe -command "& { servermanagercmd.exe -query | Select-String 'Application Server' -Context 0,13 }"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With