--% Stop parsing input as PowerShell commands or expressions.

When calling an executable program in PowerShell, place the stop-parsing symbol before any program arguments.

      PowerShell_commands --%  non-powershell_arguments/expressions

The stop-parsing symbol (--%), introduced in PowerShell 3.0, directs PowerShell to refrain from interpreting any further input on the line as PowerShell commands or expressions.


Call a VBScript or batch file:

PS C:\> & cmd.exe --% /C "C:\demo files\email.cmd" %USERNAME%

PS C:\> & cmd.exe /C C:\Batch\demo.cmd test 123

PS C:\> & cscript.exe --% -nologo "H:\export scripts\export.vbs"

"The big divide in this country is not between Democrats and Republicans, or women and men, but between talkers and doers" ~ Thomas Sowell

Related PowerShell Cmdlets

Invoke-Command - Run commands on local and remote computers.
Invoke-Expression - Run a PowerShell expression.
Invoke-Item - Invoke an executable or open a file (START).
Start-Process - Start one or more processes, optionally as a specific user.
& (call) - Run a command script.
. (source) - Run a command script in the current shell (persist variables and functions).

Copyright © 1999-2024 SS64.com
Some rights reserved