|
Set-Content not updating file after get-content and forEach-Object I have a file I need to append a value to the end of a specific line of text
(in a random location in the file).
First entry works (replaces text in file) second one does not update file at
the end of the line. I can't use the first entry because I can't do a
-replace.
1# (get-content $file) | foreach-object {$_ -replace "Group Membership","My
Membership"} | Set-Content $file
2# (Get-Content $File) | ForEach-Object {if
($_.contains("S-1-5-32-545__Members") -eq $true) {$_ = $_+",*S-1-5-4"
}} | Set-Content $File
Even though $_ is being updated with the new value, that new value is not
being passed on to the Set-Content command. |