Several weeks ago I posted an entry on creating configuration files. This same technique can also work with XML files. I’m still working on a more advanced technique but wanted to share this simpler approach.
Tag: Configuration
Cool Config Creation
In my recent Special Forces PowerShell class, one of the students brought up a challenge he was facing when we were talking about the -f replacement operator. This is a handy way to build strings.
PS C:\> “Hello, {0}. It is now {1} and you have {2} processes running.” -f $env:username,(get-date).ToShortDateString(),
(get-process | measure-object).count
Hello, Jeff. It is now 5/5/2009 and you have 82 processes running.
Paul needed to build configuration files and was looking for an easy way, perhaps using a here string as a template. We tossed around a few ideas. When I got home I decided to see what I could come up with. What I have is a proof of concept really, but it might get you started.