Formatting strings in PowerShell is easy, just include the variable inside the string and it does it automatically, right? What about when you are using variable values (i.e. $ds.count)?
Then you have to write an ugly line of code like:

I’m sure your thinking, ah that’s not too bad. But what if you had four or five value strings to put together? There is a better way to concatenate strings with variables values, it’s called Formatting a String. This is accomplished through .Net, and looks like:

And it works with more than one value:

The basics of the String.Format Method is to provide an indexed set of overloads into the string. Each overload is represented by the {0} notation, where the number inside the curly bracket is the indexed location of the overload. To read more about the method, check out the MSDN Article.

Written by Roger Delph