PoshCode Archive  Artifact [c53a240503]

Artifact c53a240503da8f92e92b30548df4983aa4934e1a16ab18da71df06a7f00fe035:

  • File Update-web-config.ps1 — part of check-in [806fbf1bed] at 2018-06-10 13:34:20 on branch trunk — The beauty of IIS web.config files is they are just text files. This function can be used to update values such as computer names in connection strings or any other matched string. Note that the replace function is case sensitive. (user: anonymous size: 843)

# encoding: ascii
# api: powershell
# title: Update web.config
# description: The beauty of IIS web.config files is they are just text files. This function can be used to update values such as computer names in connection strings or any other matched string.  Note that the replace function is case sensitive.
# version: 0.1
# type: function
# author: anonymous
# license: CC0
# function: Update-WCContents
# x-poshcode-id: 4000
# x-archived: 2015-05-05T01:18:18
# x-published: 2015-03-06T21:06:00
#
# Update-WCContents -File C:\folder\web.config -SearchString “some value” -NewValue “some new value”
#
Function Update-WCContents($File,$SearchString,$NewValue){
    $Contents = Get-Content -Path $File
    $Contents | %{$_.Replace($SearchString,$NewValue)} | Set-Content $File    
} # End Update-WCContents Function