PowerShell:从变量中删除或替换引号 [英] PowerShell: remove or replace quote marks from variable

查看:119
本文介绍了PowerShell:从变量中删除或替换引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Get-EventLog 设置一个变量,然后使用事件 ID 描述设置另一个变量.然后我使用 blat.exe 将此信息通过电子邮件发送给一个组.

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.

描述中包含引号.引号导致 blat 以错误退出.

The description contains quotation marks. The quotation marks are causing blat to exit with error.

有没有办法从 event.Message 中删除引号并用空格或其他东西替换它们?

Is there a way to remove the quotes from the event.Message and replace them with a space or something?

推荐答案

实际上我刚刚明白.引号和双引号的数量让我感到困惑,但这已经奏效,并且 blat 没有出错.

I actually just got it. The number of quotes and double quotes was confusing me, but this has worked and blat did not error.

$var -replace '"', ""

那些引号是:单引号、双引号、单引号、逗号、双引号、双引号.

Those quotes are: single, double, single, comma, double, double.

这篇关于PowerShell:从变量中删除或替换引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆