# Remove bytes from sizes / create column?

**URL:** <https://forums.powershell.org/t/remove-bytes-from-sizes-create-column/899>\
**Category:** PowerShell Help\
**Created:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/remove-bytes-from-sizes-create-column/899 "2011-12-31T18:30:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![archives](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@archives](https://forums.powershell.org/u/archives)\
**Post date:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/remove-bytes-from-sizes-create-column/899/1 "2011-12-31T18:30:00Z")

</div>

by nharvey at 2013-04-24 08:22:20

> GM all,  
>   
> when I run `Get-MailboxDatabase -Status | ft name,databasesize,availablenewmailboxspace -auto` the output looks great, but is there a way to get rid of the bytes number, so it just shows the size in GB?   
>   
> Here’s an example:  
> `Name DatabaseSize AvailableNewMailboxSpace---- ------------ ------------------------IT 18.38 GB (19,738,460,160 bytes) 38.19 MB (40,042,496 bytes)`  
>   
> The goal would be to easily export and run calculations on it.   
> Thank you in advance for any help!

by ArtB0514 at 2013-04-24 09:15:58

> One way would be to do this:  
> `Get-MailboxDatabase -Status | Format-Table name,databasesize,@{Name='AvailableSpace';Expression={($.availablenewmailboxspace.Split(' ('))[0]}} -AutoSize`

_by mjolinor at 2013-04-24 09:23:27_

_> There’s two different solutions to that problem, and which one you need to use is going to depend on the environment you’re running the command in.  
>   
> If you’re running from an EMS shell, those Value properties should have a .ToBytes() method that will produce an int byte count that you can use with math operations.  
>   
> If you’re running in an implicit remoting session, then what you got back was a deserialized object with no methods, and that property is just a string and you’ll have to parse the byte count out of the string.  
>   
>   
> `-replace '.+&#40;(.+)&#41;','$1' -replace '\D'`_

_by ArtB0514 at 2013-04-24 11:24:18_

_> [quote]If you’re running in an implicit remoting session, then what you got back was a deserialized object with no methods, and that property is just a string and you’ll have to parse the byte count out of the string.[/quote]  
>   
> Sorry, that’s what I was doing and should have said so._

_by nharvey at 2013-04-24 15:01:18_

> _Thank you both for the responses._  
>   
> _Art,  
> Your command shows this:  
> `[PS] C:\Windows\system32>Get-MailboxDatabase -Status | Format-Table name,databasesize,@{Name='AvailableSpace';Expressio={($`_`.availablenewmailboxspace.Split(' ('))[0]}} -AutoSizeName DatabaseSize AvailableSpace---- ------------ --------------IT 18.51 GB (19,872,677,888 bytes)`  
>   
> And sorry Mjol,  
> Where do I add that line of code?

by mjolinor at 2013-04-24 15:08:46

> Like this:  
>   
> `Get-MailboxDatabase -Status | ft Name, @{l='DB_Size';e={$.DatabaseSize -replace '.+&#40;(.+)&#41;','$1' -replace '\D'}}, @{l='AvailableSpace';e={$.AvailableNewMailboxSpace -replace '.+&#40;(.+)&#41;','$1' -replace '\D'}} -AutoSize`

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:57pm UTC](https://forums.powershell.org/t/remove-bytes-from-sizes-create-column/899/2 "2024-05-16T20:57:53Z")

</div>

Closed on May 16, 2024, 8:57pm UTC


