Skip to content

escapePowerShellCommand

escapePowerShellCommand(cmd): string

Defined in: command/escape-powershell-command.ts:15

Escape any characters in a string that might be used to trick a PowerShell command into executing arbitrary commands.

It escapes the following characters by adding a backtick () before them: '"$#&|;,(){}[]<>@, \n and \xFF.

The backtick is PowerShell’s escape character, the counterpart of the backslash escapePosixShCommand uses and the caret escapeWin32CmdCommand uses.

string

The command to escape

string

The escaped command