【发布时间】:2014-07-07 17:17:43
【问题描述】:
我有一个 aspx 文件,我正在尝试使用 powershell 1.0 进行更新。该文件如下所示:
<html>
<head>
<title>Welcome!</title>
我用:
(Get-Content "C:\documents and settings\login.aspx") | ForEach-Object{$_ -replace "<title>Welcome!</title>","<title>Welcome! Warning...</title>"} | Set-Content "C:\documents and settings\login.aspx"
它什么也没做。
但是,我使用:
(Get-Content "C:\documents and settings\login.aspx") | ForEach-Object{$_ -replace "<title>Welcome!","<title>Welcome! Warning..."} | Set-Content "C:\documents and settings\login.aspx"
它取代了它,但显然是错误的方式:
<html>
<head>
<title>Welcome! Warning...</title></title>
这里发生了什么?我希望我的第一个示例能够工作
【问题讨论】:
-
使用您编写的代码,我无法复制问题。第一个例子对我来说很好。
标签: html powershell replace