Software_Word_Remove_SpecialCharacters.ps1

function Word-RemoveSpecialCharacters {
    param (
        [string]$documentPath
    )
    
    $wordApp = New-Object -ComObject Word.Application

    $document = $wordApp.Documents.Open($documentPath)

    foreach ($paragraph in $document.Paragraphs) {
        $cleanedText = $paragraph.Range.Text -replace '[^\w\s]', ''

        foreach ($hyperlink in $paragraph.Range.Hyperlinks) {
            $cleanedText = $cleanedText -replace [regex]::Escape($hyperlink.Address), $hyperlink.TextToDisplay
        }

        $paragraph.Range.Text = $cleanedText
    }

    $document.Save()
    $document.Close()

    $wordApp.Quit()

    Write-Host "Special characters removed and hyperlinks replaced in $documentPath."
}