I have the following script that is customizing several web.config files (from an outside vendor). I have discovered that some of these files have an unrecognized character in them (hex C2 A0). Once these files run through my script (hex C2 A0) is replaced with (hex EF BF BD) which causes an encoding error in the file.
Can someone help me with the search/replace verbage to use to replace (hex EF BF BD) with a space (hex 20)?
$Files=Get-ChildItem C:\Temp\configs -Recurse -Filter web.config #| select FullName
foreach ($File in $Files) {
$WebConfig=$File.FullName
(Get-Content $WebConfig) | ForEach-Object {$_ -replace '^.*address="gzip".*$',""} | Set-Content $WebConfig
(Get-Content $WebConfig) | ForEach-Object {$_ -replace 'binding="customBinding"','binding="basicHttpBinding"'} | Set-Content $WebConfig
(Get-Content $WebConfig) | ForEach-Object {$_ -replace '<add key="WcfBindingType" value="customBinding"/>','<add key="WcfBindingType" value="basicHttpBinding"/>'} | Set-Content $WebConfig
(Get-Content $WebConfig) | ForEach-Object {$_ -replace 'c:\css_netpack60\ ','d:\css_netpack60\'} | Set-Content $WebConfig
(Get-Content $WebConfig) | ForEach-Object {$_ -replace 'bindingConfiguration="https"','bindingConfiguration="http"'} | Set-Content $WebConfig
#(Get-Content $WebConfig) | ForEach-Object {$_ -replace '0xEF 0xBF 0xBD','0x20'} | Set-Content $WebConfig
#(Get-Content $WebConfig) | ForEach-Object {$_ -replace 'U+00A0','U+0020'} | Set-Content $WebConfig
}