Friday, August 25, 2017

Output of formatting cmdlets is not suitable for use as the represented object

New PowerShell users sometimes get confused between an object and its textual, formatted, on-screen representation. PowerShell provides a handful of formatting cmdlets (those with the Format verb), whose output can be much more informative than the default stringification. Of course, formatting an object still creates a string, which is not the same as the original object even if it prints identically. Even putting a string through a formatting cmdlet might get extra whitespace onto it that can confuse other cmdlets. Format-Wide with -Property does this, for instance.

No comments:

Post a Comment