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

Powershell add code after specific character in a string

我正在编写一个脚本来获取一些 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>

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

使用以下方法解决:

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