I'm using Get-EventLog to set a variable, and then setting another variable with the event ID description. I then use blat.exe to email this information to a group.
The description contains quotation marks. The quotation marks are causing blat to exit with error.
Is there a way to remove the quotes from the event.Message and replace them with a space or something?
Use the PowerShell String replace() method or replace operator to replace the double quotes in PowerShell with empty spaces or single quotes. e.g. $str.
The Splatting Operator To create an array, we create a variable and assign the array. Arrays are noted by the "@" symbol.
To remove double quotes from a string:Call the replace() method on the string. The replace method will replace each occurrence of a double quote with an empty string. The replace method will return a new string with all double quotes removed.
If the variable is a String object then you can do the following:
$Variable.Replace("`"","")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With