# 接收4个参数,用于替换 参数1 文件中的 参数2:参数3 为 参数2:参数4 param ( [string]$filePath, [string]$key, [string]$oldValue, [string]$newValue ) # 替换 $filePath 文件中的 $key:$oldValue 为 $key:$newValue Write-Output "replace $filePath ${key}:$oldValue to ${key}:$newValue then save to $filePath" (Get-Content $filePath) -replace "${key}:$oldValue", "${key}:$newValue" | Set-Content $filePath Get-Content $filePath