Quantcast
Channel: PowerShell General
Viewing all articles
Browse latest Browse all 10624

Preparing a string that contains both single and double quotes for PowerShell

$
0
0

I'm using PowerShell in a Microsoft Orchestrator 2012 activity.  Manipulating data from Microsoft SCOM 2012 Alert.  When subscribing to the Description string from SCOM alert, the string can contain Single and Double quotes.  PowerShell doesn't like this.  I've given examples here.  The string [ .... ] is populated by Orchestrator.  I put double quotes around it as needed.

$foo = "[This string has "Double" quotes and single ' quotes.]"

It will try to execute the cmdlet Double

So I try with single quotes around the replaceable text;

$foo = '[This string has "Double" quotes and single ' quotes.]'

This fails as well.

I'm completely aware of escaping quote characters, yet I do not have that ability here.  The [....string...] is populated by Orchestrator 2012 at runtime.  How can I possibly handle this string and clean it up so I can assign it to a variable and continue processing?


Viewing all articles
Browse latest Browse all 10624

Trending Articles