PowerShell.exe arguments

You can use PowerShell.exe to start a Windows PowerShell session from the command line of another tool, such as Cmd.exe, or use it at the Windows PowerShell command line to start a new session. Use the parameters to customize the session.

       [-EncodedCommand <Base64EncodedCommand>]
       [-ExecutionPolicy <ExecutionPolicy>]
       [-InputFormat {Text | XML}] 
       [-OutputFormat {Text | XML}] 
       [-PSConsoleFile <FilePath> | -Version <Windows PowerShell version>]
       [-WindowStyle <style>]
       [-File <FilePath> [<Args>]]
       [-Command { - | <script-block> [-args <arg-array>]
                     | <string> [<CommandParameters>] } ]

PowerShell[.exe] -Help | -? | /?

When passing command line argument to powershell.exe, it should be placed before the “-Command” argument. If “-Command” comes first, the other arguments won’t be used.

If you need to pass a parameter to the ps script itself, you’ll have to use the “& – call operator”, like here

powershell -ExecutionPolicy Unrestricted -Command "& 'D:\scripts\script.ps1' -Parameter1 parameter1"

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top