I want to replace 4 strings with 4 another ones and write them to file.
$file = 'C:\Defender.psd1'
(Get-Content $file) | ForEach-Object {
$_.replace("'MSFT_MpSignature.cdxml',", "'MSFT_MpSignature.cdxml')")
$_.replace("'MSFT_MpWDOScan.cdxml')", "")
$_.replace("'Remove-MpThreat',", "'Remove-MpThreat')")
$_.replace("'Start-MpWDOScan')", "") `
} | Out-File $file
But instead of this every string in the file has been duplicated 4 times. Script will be used for PowerShell 4 and 5.1.