在我的 PowerShell 脚本中,我收到一个我不理解的错误。
错误是:
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.
Invalid regular expression pattern:
Menu "User" {
Button "EXDS" {
Walk_Right "EXDS"
}
}
.
At C:\test.ps1:7 char:18
+ ($output -replace <<<< $target) | Set-Content "usermenuTest2.4d.new"
+ CategoryInfo : InvalidOperation: (
Menu "User" {...do"
}
}
:String) [], RuntimeException
+ FullyQualifiedErrorId : InvalidRegularExpression
我的脚本将文件读入字符串(字符串 A),然后尝试从另一个文件中删除字符串 A。这个错误是什么意思,我该如何解决?
我的代码:
#set-executionpolicy Unrestricted -Force
#set-executionpolicy -scope LocalMachine -executionPolicy Unrestricted -force
$target=[IO.File]::ReadAllText(".\usermenuTest1.4d")
$output=[IO.File]::ReadAllText(".\usermenuTest2.4d")
($output -replace $target) | Set-Content "usermenuTest2.4d.new"