在我的PowerShell脚本中,我收到了一个我不明白的错误。字符串替换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)然后尝试从另一个文件中删除String一个。这个错误意味着什么,我该如何修复它?
我的代码:
#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"
如果'$ target'或'$ output'是'$ null'否'InvalidRegularExpression' 异常将会是trhow。不是这个错误。 – 2013-05-03 11:07:39