There are many different ways how objects can be transformed into text. In case you sometimes get confused, here is a quick refresher. Take a look:

There are three fundamental ways how objects turn into text.

$a = 4.5
# simple conversion
$a.ToString()
# slightly better conversion
"$a"
# richest conversion
$a | Out-String

With simple objects, the result of these methods won’t differ. With more complex objects, however, the results may look very different. Take a look at arrays:

$a = 1,2,3

$a.ToString()

"$a"

$a | Out-String

And check how complex objects are converted to text:

$a = Get-Process

$a.ToString()

"$a"

$a | Out-String

Twitter This Tip! ReTweet this Tip!

Anonymous