Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • u are the best man <3 it's working Commented May 24, 2016 at 15:46
  • 3
    If the command to be executed has quotes, they must be doubled. Example : powershell -command "dir ""c:\Program Files"""
    – Myobis
    Commented Mar 29, 2018 at 9:28
  • 1
    @myobis or you can just use single quotes powershell -command " dir 'C:\Program Files' "
    – SimonS
    Commented Mar 29, 2018 at 10:06
  • 5
    @myobis Actually, doubling the quotes doesn't work (in Windows 10 cmd). But using backslash escaping did: powershell -command "dir \"c:\Program Files\" "
    – wisbucky
    Commented Apr 3, 2018 at 20:43
  • You need to temporarily override the execution policy to run a Powershell script file.: powershell.exe -ExecutionPolicy RemoteSigned -File %~dp0\test.PS1. Commented Jul 14, 2023 at 13:27