I am trying to modify several values of a PowerShell script template prior to execution. The approach I took was to use the Get-Content
command to read the template file, then to use the replace
operand to replace the content with a content of my choosing, and then the Set-Content
command to update the file, then execute the script. However, according to the error messages that I encounter, it seems that the modified file is not running, but the template one.
The thing I find hard to understand is why, as I use the Get-Content
once again and print the result prior to execution, where I witness that the file did change.
I use simple PowerShell scripting with no threads or so ever, the script is being executed on an Azure VM via the Run-Command
feature. I wonder why it happens.
Can anyone please explain?