How to escape ampersands, semicolons, and curly braces in command-line powershell params?

powershell .\makeConfig.ps1 -password "'xxx<xxxx;xxxxx&x.xxxx}xx/xxx'" -otherparam 3

Here

  • outer " double quotes would escape all cmd poisonous characters e.g. <, & etc. excepting " itself and % percentage sign (and ! exclamation mark if delayed expansion is enabled) while
  • inner ' apostrophes (single quotes) would escape all powershell ones (excepting ' apostrophe itself).

However, exceptions noticed above could be escaped as well…
Based on both Escape characters, Delimiters and Quotes articles:

  • in cmd and batch-file
  • in powershell

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)