Is it possible to write self-modifying PowerShell scripts?
Suppose I have a script named foo.ps1
:
"Write-Host `"Goodbye world`"" | Set-Content "foo.ps1"
Write-Host "Hello world"
This script prints out Hello world
. What techniques could I use to get it to print out Goodbye world
?