by nharvey at 2013-04-24 08:22:20
GM all,by ArtB0514 at 2013-04-24 09:15:58
when I runGet-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!
One way would be to do this:by mjolinor at 2013-04-24 09:23:27Get-MailboxDatabase -Status |
Format-Table name,databasesize,@{Name='AvailableSpace';Expression={($.availablenewmailboxspace.Split(' ('))[0]}} -AutoSize
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.by ArtB0514 at 2013-04-24 11:24:18
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 '.+((.+))','$1' -replace '\D'
[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]by nharvey at 2013-04-24 15:01:18
Sorry, that’s what I was doing and should have said so.
Thank you both for the responses.by mjolinor at 2013-04-24 15:08:46
Art,
Your command shows this:[PS] C:\Windows\system32>Get-MailboxDatabase -Status | Format-Table name,databasesize,@{Name='AvailableSpace';Expressio
={($.availablenewmailboxspace.Split(' ('))[0]}} -AutoSize
Name DatabaseSize AvailableSpace
---- ------------ --------------
IT 18.51 GB (19,872,677,888 bytes)
And sorry Mjol,
Where do I add that line of code?
Like this:Get-MailboxDatabase -Status |
ft Name,
@{l='DB_Size';e={$.DatabaseSize -replace '.+((.+))','$1' -replace '\D'}},
@{l='AvailableSpace';e={$.AvailableNewMailboxSpace -replace '.+((.+))','$1' -replace '\D'}} -AutoSize