Formatting Output of PowerCLI

Size value is too long when I grab snapshot size of a VM. It’s something like the screenshots below.

中文版

It makes the column too wide when I try run some reports. There is a simple way to keep only 2 decimals.

$a=Get-Snapshot -VM XXXX

$a | select Description,VM,@{Name="SizeGB";Expression={"{0:N2}" -f $_.SizeGB}}

If you want keep no decimals just replace the “2” with “0”.

Advertisements

Author: Wu

VCP, MCSE, CCNA

1 thought on “Formatting Output of PowerCLI”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s