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

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -