I have a long custom application config file for an application that runs on workstations, with some text elements that have to be changed manually from system to system.
This script is an attempt to make my life easier -
$content = Get-Content("C:\file.text")
$content = $content.replace("%DoTheThing?%","TRUE")
$content = $content.replace("%Place%","SpecificPlace")
$content = $content.replace("%SystemName%",$env:HOSTNAME)
$content = Set-Content("C:\file.text")
When I execute the script, the first text items get replaced correctly, the third gets deleted, instead of replaced. Being new to Power Shell, How do I correct this - such that the actual system name is replacing the %SystemName% section?
$Env:HOSTNAME
isn't an environment variable. Try$Env:COMPUTERNAME