command line arguments - Keep quotes in $args using PowerShell -


is possible keep quotes in $args?

the script called this:

.\test1.ps1 a=application o="this object" msg_text="this text" 

the quotes mandatory further processing. there way keep them inside $args?

the way can think of without being able modify input parameters still require modifying command called somewhat.

in order preserve quotes, perhaps try capturing full command-line powershell script called with.

so put in test1.ps1 script:

write-host (get-wmiobject -query "select commandline win32_process commandline '%test1%'").commandline 

then returned if script called in manner:

ps c:\temp> powershell .\test1.ps1 a=application o="this object" msg_text="this text" "c:\windows\system32\windowspowershell\v1.0\powershell.exe"  .\test1.ps1 a=application "o=this object" "msg_text=this text" 

this possible if new instance of powershell called, however, otherwise parameters won't available method:

ps c:\temp> .\test1.ps1 a=application o="this object" msg_text="this text" > zzz3.txt  ps c:\temp> 

of course if approach taken, you'll need parse input arguments manually, might able of $args object. it's long-shot, preserve quotes.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -