powershell 替换连接字符串
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 替换连接字符串相关的知识,希望对你有一定的参考价值。
param([string]$oc,[string]$nc)
Write-Host "Searching for: "$oc
Get-ChildItem test.config -recurse |
Foreach-Object {
$c = ($_ | Get-Content)
$n = $c -replace [RegEx]::Escape($oc), $nc
if($c -ne $n) {
Write-Host $_.FullName
if($nc -ne $NULL) {
Write-Host " Replacing $oc with $nc"
[IO.File]::WriteAllText($_.FullName, ($n -join "`r`n"))
}
}
}
Invoke like
.\ConnectionChange.ps1 -oc aspen\reporting -nc dw
oc: old connection
nc: new connection
以上是关于powershell 替换连接字符串的主要内容,如果未能解决你的问题,请参考以下文章