locked
Importing a String that might have single and/or double quotes RRS feed

  • Question

  • I work with Orchestrator and SCOM and i am working on a powershell script to grab SCOM alert info and send it to MS Teams.  THe problem is that the SCOM Alerts descriptions come in sometimes with single and or double quotes.  Most of the time there is no issue (no quotes), but there are some alerts that have one or the other, and even sometimes both.  How do you handle this?

    Ex:

    $Message = "<SCOM Description from SCOM Alert>"

    Tried 

    $Message =

    @"

    <SCOM Description from SCOM Alert>

    "@

    Which didn't work.  Tried to put in Try-Catch, didn't work.

    Monday, July 22, 2019 11:22 PM

All replies

  •  didn't work.

    What exactly didn't work? 

    Monday, July 22, 2019 11:32 PM
  • Which didn't work.  Tried to put in Try-Catch, didn't work.

    What you are asking is very vague.  An alert comes in a variable. Quotes inside a variable have no issues they are just characters in a variable.

    You need to take a few minutes and learn how to ask a technical question in a technical forum.

    Read the following as it will help you understand how to ask a clear technical question.

    How to ask questions in a technical forum


    \_(ツ)_/

    Monday, July 22, 2019 11:49 PM
  • Why not use powershell scom module to get the alerts?
    Get-SCOMAlert

    Tuesday, July 23, 2019 10:24 AM