How to handle variable containing parentheses in Powershell -


i'm trying create script name of file/directory getting right-clicked, modify , put modified string on clipboard.

this works nicely long string not contain parentheses. if so, getting error when trying it. e.g. if $args contains "c:\document(draft).pdf" , i'm trying echo using

write-host $args 

i'm getting following error:

the term 'draft' not recognized name of cmdlet, function, script file, or operable program.

how handle variables containing parentheses in such case?

use single quoatation marks. code works:

$args = 'c:\document(draft).pdf'  if ($args -contains 'c:\document(draft).pdf') { write-host $args } 

output:

c:\document(draft).pdf 

Comments

Popular posts from this blog

How to check data type in C++? -

javascript - Is getTimezoneOffset() stable during daylight saving transition? -

sql server - SQL Query returns one result, does not return 0 or NULL result -