[英]Find and replace domain address in xml file
I am looking for assistance with a script or piece of code to add to an existing script which will look up the domain portion of a user SIP address and replace it with a new domain. 我正在寻找有关脚本或一段代码的帮助,以添加到现有脚本中,该脚本将查找用户SIP地址的域部分并将其替换为新域。
The exiting script changes the main user address which works fine, but I need an additional part which will lookup any addresses in the xml file matching @domainA.com
and replace it with @domainB.com
退出的脚本更改了可以正常工作的主用户地址,但是我需要一个额外的部分,它将在xml文件中查找与
@domainA.com
匹配的任何地址,并将其替换为@domainB.com
Probably the easiest way would be to use a regex replace: 可能最简单的方法是使用正则表达式替换:
(Get-Content C:\imports\$username\DocItemSet.xml -raw) -replace '@domainB\.com', '@domainA.com' |
Set-Content C:\imports\$username\DocItemSet.xml
Note: You probably want to specify the -Encoding
parameter within the Set-Content
cmdlet. 注意:您可能想要在
Set-Content
cmdlet中指定-Encoding
参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.