Author  Posts 
This is probably a really simple answer but I cannot figure out what I am doing wrong. I have this code: Select Name, @{ n = 'FreeSpace'; e = { [int]($_.FreeSpace/1GB) } }, @{ n = 'Capacity'; e = { [int]($_.Capacity/1GB) } }, @{ n = 'PercentFree'; e = { [math]::round($_.FreeSpace / $_.Capacity * 100) } }, and this works fine. The only thing I want to do is add a % sign after the value of "PercentFree" and I just don't know the correct syntax. @{ n = 'PercentFree'; e = { [math]::round($_.FreeSpace / $_.Capacity * 100) } '%' }, but know that does not even look right, let alone work...lol Thanks, 

"$([math]::round($_.FreeSpace / $_.Capacity * 100))%" Try that inside the expression 

Use the format operator. @{n='PercentFree';exp={"{0}%" f [math]::round($_.FreeSpace / $_.Capacity * 100) }} 

Thanks, this worked great! I didn't even know about the format operator. 

Thought this could be worth mentioning: You don't need to oneline the statement in the expression part. It's a full script block and you could write more complex stuff on multiple lines (or with semicolons): PS M:\> GetItem .  SelectObject @{n="Test"; e={$x=123; $y=321; $z = (TestConnection "powershell.org" Count 2  MeasureObject Property "ResponseTime" Sum).Sum; $x + $y + $z}} Test It might hurt the readability if you put many things in the expression, but the possibility is there ðŸ™‚ 

Thanks!!! 
You must be logged in to reply to this topic.