Subscribe to Windows IT Pro
September 23, 2010 12:01 AM

Q. Do normal Windows commands run in PowerShell?

Windows IT Pro
InstantDoc ID #125890
Rating: (1)

A. Generally, yes. There are times, however, when PowerShell's parsing of commands results in unexpected and confusing errors. Sometimes, you'll need to enclose your entire command string within quotation marks and use the shell's invoke operator to run the command:

&"SC.EXE STOP WUAUSERV"

That's a good example because it uses the external Sc.exe command rather than PowerShell's internal SC alias. If you just run

SC STOP WUAUSERV

the built-in SC command will run, accepting STOP and WUAUSERV as input parameters. As a result, you'll get an error.

 

Do you have a Windows PowerShell question? Why not submit it to Don? Post your question at windowsitpro.com/go/SubmitFAQ and you might see your answer online! Find more PowerShell FAQs, articles, and other resources at windowsitpro.com/go/DonJonesPowerShell.

Related Content:

ARTICLE TOOLS

Comments
  • elisagie
    1 year ago
    May 31, 2011

    Not exactly. here's what i tried followed by the error:
    &"sc query w3svc"
    The term 'sc query w3svc' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
    the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:2
    + & <<<< "sc query w3svc"
    + CategoryInfo : ObjectNotFound: (sc query w3svc:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.