Hi,
I've often faced the same problem myself, I basically work around it in one of two ways depending on the situation:
- Really complex stuff that needs to get passed to a PowerShell script
- Fairly simple stuff (but has special characters/formatting)
For #1, I end up writing the string to an SQL scratch table that I keep for just such a purpose, and then read the data from the SQL table into the PowerShell script by passing it the row ID. I just found for really complex strings it was much easier than trying to deal with escaping or replacing characters.
For #2, I use string replacement in CAPA, and then in PowerShell to reverse the changes.
So an example with a simple JSON string:
Process[OpName].TestJSON = '{"fields":{"customfield_11600":"305455","customfield_13501":"338492"}}';
Process[OpName].TestJSON = Process[OpName].TestJSON.replace(/"/g,"~~");
I would pass Process[OpName].TestJSON to my PowerShell script as a parameter, and then i the PowerShell script I would reverse the change with $args.Replace("~~","""")
Here is the Parameter:
The PowerShell script I used for this example is:
write-host $args
write-host $args.Replace("~~","""")
And here is the output from the scriptOutput:
I wish there was an easier way to interact with PowerShell and pass parameters and secure passwords, but I have yet to find one (let me know if you do).
Hope this helps,
Ian