That code works. When you remove the final pipe and Set-Content cmdlet, does it write the correct data to the screen? My first thought is that you’re working with a read-only file; however, that would probably indicate an error. Maybe not, so try the Set-Content cmdlet with the -Force parameter. Speaking of errors, are you seeing any errors; you didn’t indicate that one way, or another.
The “Value” error at the end is indicating that nothing is being supplied to the Set-Content cmdlet’s mandatory -Value parameter. Type Set-Content by itself into the PowerShell console and you’ll see what I mean. In fact, you’ll see this with any cmdlet, or function, that requires a specific parameter(s) have a value when it’s run.
I have this working with an example file that (at times), both did, and didn’t contain ‘shared_buffers = 32MB’ and it worked. I’m not sure what else to say. Can you post the beginning to end run, so we can see everything? Providing my image shows below, you should be able to see this worked for me.