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”.