Works from cmd prompt but not from powershell?

Ted Penner
Ted Penner used Ask the Experts™
on
Why would the command below work from the command line but not from PowerShell? From PowerShell, I get the error "FIND: Parameter format not correct" where I do not get that result in the command line. What is the correct PowerShell command? I resolve?
systeminfo /S hostname | find "KB3021952"

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2018
Distinguished Expert 2018
Commented:
Because Powershell swallows the double quotes around the string when parsing the command line (and unlike most tools, find.exe insists on the search string being enclosed in quotes). Ironically enough, if there were a space in your search string, it would work, because then PS would keep the quotes ...
You'll need
 systeminfo /S hostname | find "`"KB3021952`""

Open in new window

Or use Select-String:
 systeminfo /S hostname | Select-String -SimpleMatch "KB3021952"

Open in new window

Ted PennerSoftware Engineer

Author

Commented:
Thank you!!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial