Powershell在字符串中的特定字符后添加代码

时间:2019-08-29 14:20:32

标签: powershell character add

我正在编写脚本以获取一些Windows报告并通过邮件[http]发送。 问题是,当我发送邮件时,它不尊重变量中的新行,因此我想在每个之后添加
标记。 [点]。它将解决我的问题。

例如:

@{Message=SureBackup job 'example' finished with Warning.
Job details: [example]: Cannot detect IP address. 
Ping test will be skipped}

如果我将其放在变量中,它将尊重新行,但是当我发送它时...

@{Message=SureBackup job 'example' finished with Warning. Job details: [example]: Cannot detect IP address. Ping test will be skipped}

这是结果。

我不知道如何替换为:

@{Message=SureBackup job 'example' finished with Warning.<br>
Job details: [example]: Cannot detect IP address.<br> 
Ping test will be skipped}<br>

它将解决我们所有的问题。

1 个答案:

答案 0 :(得分:1)

已解决:

$info -replace "[.]",".<br>"