I'm trying to create a script to get the name of a file/directory which is getting right-clicked, modify it and put the modified string on the clipboard.
This works nicely as long as the string does not contain parentheses. If so, I am getting an error when trying to do anything with it. E.g. if $args contains "C:\Document(draft).pdf" and I'm trying to echo it using
Write-Host $args
I'm getting the following error:
The term 'draft' is not recognized as the name of a cmdlet, function, script file, or operable program.
How to handle variables containing parentheses in such a case?