~1 min read

Categories

2364129390_4fe946df4a_m Yet again, long time no post! .net Format Strings are very useful when it comes to taking control over the output of your scripts. e.g.: [code language=”powershell”] ‘{0:t}’ -f (Get-Date) #output: h:mm tt ‘{0:n1}’ -f 2.45 #output: 2.5 [/code] The problem with those Format Strings is, that hardly anyone can remember them. While there they are thoroughly documented and several nice folks have created cheat-sheets (e.g. here), I thought it would be nice to be able to get (at least the most common) Format Strings for a given input automatically along with the respective outputs within PowerShell. Get-FormatStringOutput The function returns output for Integer, Double, and DateTime input. You can download Get-FormatStrings from my GithHub repository or just grab the code below: https://gist.github.com/25ec562a8bb21b1899044ca7913ae7ef

shareThoughts


Photo Credit: sharkbait via Compfight cc