Skip to content

Instantly share code, notes, and snippets.

@PrateekKumarSingh
Created October 5, 2018 10:12
Show Gist options
  • Save PrateekKumarSingh/fae2545297aa6d3aea5f95385100c0ba to your computer and use it in GitHub Desktop.
Save PrateekKumarSingh/fae2545297aa6d3aea5f95385100c0ba to your computer and use it in GitHub Desktop.
# formatting strings
# no numbers in braces will throw formatting ERROR in powershell
'firstname:{} lastname:{}' -f 'prateek','singh'
# use numbers in braces to define sequence of arguments consumed by the string
'a:{0} b:{2} c:{1}' -f 'red','green','blue'
# adding leading zero
'{0:d3}' -f 5
# using hashtables for formatting
$coor = @{'latitude'= '31.24E'; 'longitude'= '-125.81N'}
"Coordinates: {0}, {1}" -f [System.Object[]]$coor.Values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment