The if block changes the value of the object but it doesn't send it through
the pipeline; add another statement inside the block that will send the
changed object through. Also, need to add an else statement to output the
lines that don't match the if condition:
(Get-Content $File) | ForEach-Object {if
($_.contains("S-1-5-32-545__Members") -eq $true) {$_ = $_+",*S-1-5-4"; $_}
else {$_}} | Set-Content $File
You can also use -replace:
(Get-Content $File) | ForEach-Object {$_ -replace "S-1-5-32-545__Members",
"S-1-5-32-545__Members,*S-1-5-4"} | Set-Content $File
--
Kiron