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


1 thought on “Formatting Output of PowerCLI

  1. Pingback: 格式化PowerCLI输出 – Wu's Blog

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.