Private/Set-StringReplacement.ps1

function Set-StringReplacement {
    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '', Scope='Function')]
    [CmdletBinding()]
    param(
        [String] $Path,
        [String] $OriginalValue,
        [String] $NewValue,
        [String] $LoggingPrefix
    )

    try {
        Write-EdenInfo "Renaming folders with '$OriginalValue' to '$NewValue'." $LoggingPrefix
        Get-ChildItem $Path -Recurse -Directory | Where-Object {$_.Name.Contains($OriginalValue)} `
            | Rename-Item -NewName {$_.Name -Replace $OriginalValue, $NewValue}
        Write-EdenInfo "Renaming files with '$OriginalValue' to '$NewValue'." $LoggingPrefix
        Get-ChildItem $Path -Recurse -File | Where-Object {$_.Name.Contains($OriginalValue)} `
            | Rename-Item -NewName {$_.Name -Replace $OriginalValue, $NewValue}
        Write-EdenInfo "Replacing '$OriginalValue' with '$NewValue' in files." $LoggingPrefix
        $totalFiles = (Get-ChildItem -Path $Path -File -Recurse | Measure-Object).Count
        $currentFile = 0
        Get-ChildItem -Path $Path -File -Recurse | Where-Object { $_ -ne $null } | ForEach-Object {
            $currentFile++;
            $complete = ($currentFile/$totalFiles)*100
            Write-Progress -Activity "Replacing '$OriginalValue' with '$NewValue'" `
                -CurrentOperation "($currentFile of $totalFiles) Checking file $_." `
                -PercentComplete $complete
            if (Test-IsAscii $_) {
                (Get-Content $_) | ForEach-Object {
                    if ($_ -ne $null -and $_.Contains($OriginalValue)) {
                        $_.Replace($OriginalValue, $NewValue)
                    } else {
                        return $_
                    }
                } | Set-Content -Path $_.FullName
            }
        }
    }
    catch {
        Write-EdenError "Error replacing '$OriginalValue' with '$NewValue' in files." $LoggingPrefix
        throw $_
    }
}