Hi,
I am bringing in data from ServiceNow "Description" field. Later on I have a powershell .NET activity that uses this subscribed variable from the previous activity.
But how would I handle the possibility that someone may type an apostrophe or a quote character in the description?
I first spotted this with a test I am doing "Andrew's Test" which of course the script failed when assigning that variable within single quotes. I resolved that by changing the single quotes in the script variable assignment to double quotes.
But thinking about this, this is now just going to fail if someone has a double quote, for the same reason.
So, the correct way would be to handle this properly regardless.
If I am doing something like this...
$snDescription = "{SUBSCRIBEDVARIABLEID}"
How can I capture within that if there are single or double quotes and escape them before assigning? Would I just have to do like...
"{SUBSCRIBEDVARIABLEID}".Replace(""", """") - I know this is wrong, but is the idea right? Or if not, how could I do this?
Thanks
Andrew