【发布时间】:2018-08-07 20:57:09
【问题描述】:
我的 PowerShell 脚本中的函数如下:
function replace-file-content([string] $path, [string] $replace, [string] $replacewith) {
(Get-Content $path) |
Foreach-Object -replace{$replace,$replacewith}|
Out-File $path
}
我得到的错误是:
ForEach-Object:无法绑定参数“进程”。无法将“System.String”类型的“-replace”值转换为“System.Management.Automation.ScriptBlock”类型。
【问题讨论】:
-
Foreach-Object {$_ -replace $replace,$replacewith}
标签: powershell