Answered by:
Parse Selected String From Variable

Question
-
I have a script that generates mailbox averages. The following PS command:
Get-Mailbox -Resultsize Unlimited | Get-MailboxStatistics | %{$_.TotalItemSize.Value.ToGB()} | Measure-Object -Average
Gives an output like this:
Count : 1563
Average : 3.30550621669627
Sum :
Maximum :
Minimum :
Property :
How do I take only the "3.30550621669627" and save is as a variable for use elsewhere?Tuesday, February 20, 2018 3:47 PM
Answers
-
Averaging Gb will give a very inaccurate answer. It throws away a large part of the number.
$justthenumber = (Get-Mailbox -Resultsize Unlimited |
Get-MailboxStatistics |
%{$_.TotalItemSize.Value.ToGB()} | Measure-Object -Average).Average
\_(ツ)_/
- Edited by jrv Tuesday, February 20, 2018 4:28 PM
- Marked as answer by shadreamer Tuesday, February 20, 2018 5:31 PM
Tuesday, February 20, 2018 4:27 PM
All replies
-
$average = Get-Mailbox -Resultsize Unlimited | Get-MailboxStatistics |
%{$_.TotalItemSize.Value.ToGB()} | Measure-Object -Average | Select Average
If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful. (99,108,97,121,109,97,110,50,64,110,121,99,97,112,46,114,114,46,99,111,109|%{[char]$_})-join''
- Edited by clayman2 Tuesday, February 20, 2018 3:49 PM edit script
Tuesday, February 20, 2018 3:49 PM -
Thanks for the amazingly fast response. Your answer pares it down nicely, but I just want the number, not the "Average" text.
This number will change with each run, but should be a consistent length.
Tuesday, February 20, 2018 4:04 PM -
Averaging Gb will give a very inaccurate answer. It throws away a large part of the number.
$justthenumber = (Get-Mailbox -Resultsize Unlimited |
Get-MailboxStatistics |
%{$_.TotalItemSize.Value.ToGB()} | Measure-Object -Average).Average
\_(ツ)_/
- Edited by jrv Tuesday, February 20, 2018 4:28 PM
- Marked as answer by shadreamer Tuesday, February 20, 2018 5:31 PM
Tuesday, February 20, 2018 4:27 PM -
That worked perfectly. Thanks.Tuesday, February 20, 2018 5:31 PM