EMS Output is Different on 2 Computers for 1 Command
Hi,
I know that Ex2010 makes all its management shell connections as remote even if it was on the same box, but my point is:
I connected to exchange from a windows 7 client on the network with powershell, and I executed the below command:
Get-Mailbox | Get-MailboxStatistics | where {$_.TotalItemSize -gt 500MB} | ft DisplayName, ItemCount, TotalItemSize
And the result I got was this: (HAD TO REMOVE THE NAMES)
And when I executed the same command on the Exchange Server's EMS I got the correct result:
I have noticed this many times, but I did not give it attention, but today I needed that output very urgently and what I got was result from a command I never executed...
So, what is possibly causing this strange result on a connection from another machine?
Could the cache causing this? and what cache? Exchange Server's IIS cache, or my systems temp files?
I don't think that the IIS on Ex is causing this, or else I'll be seeing the same problem inside the box itself (since all powershell traffic is going through the IIS - correct me please if I was wrong)...
I have Exchange Server 2010 Service Pack 1 - Update Roll Up 2
Regards
Saleh Ramadan
March 21st, 2011 7:48am
It looks like the 500MB filter isn't working in the Windows 7 PowerShell. Why that is, I can't say. It may be some arcane limitation in Remote Powershell, or just simply a bug.
What happens if you enter:
500MB
on a line by itself in Windows 7 PowerShell? Does it properly translate (like it does on my Windows 7 PC)?
PS C:\Windows\system32> 500MB
524288000
PS C:\Windows\system32>Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."
Free Windows Admin Tool Kit Click here and download it now
March 21st, 2011 12:09pm
Thank you for your reply Ed,
Actually, when I type (500MB) I get the same result you got:
PS C:\> 500MB
524288000
PS C:\>
Above is from the same Windows 7 machine I was talking about; The output on the server is the same also
I tried to do the same command in my first post, but with changing the 500MB to 700MB, and I got the same thing, different results on the server and the Win7 client...
I will try to do one thing, I'll write the Get-MailboxStatistics command, and I will replace the MB filter with Bytes, the I'll reply back here with the result...Saleh Ramadan
March 22nd, 2011 1:32am
Update:
I just executed the command while replacing the MB value with the Bytes value, and what I got was the same, I don't know if this was happening before, or was happening with someone else
I have also executed the command from another computer (a server actually) and also I was getting the same different outputs
Where do I look in the server to know what is going on with this?Saleh Ramadan
Free Windows Admin Tool Kit Click here and download it now
March 22nd, 2011 1:49am
What happens if you run:
Get-Mailbox | Get-MailboxStatistics | ft DisplayName, ItemCount, TotalItemSize
on both systems? And please post the text, not pictures.
Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."
March 23rd, 2011 12:16pm
When I execute the command:
Get-Mailbox | Get-MailboxStatistics | ft DisplayName, ItemCount, TotalItemSize
I get this from the Exchange Server: (which is the correct result)
DisplayName ItemCount TotalItemSize
----------- --------- -------------
Administrator 10 68.55 KB (70,193 bytes)
Discovery Search Mailbox 2 884 B (884 bytes)
Quarantine Mailbox 41 2.078 MB (2,178,532 bytes)
Info Mailbox 115 15.66 MB (16,423,515 bytes)
Admin 17 96.94 KB (99,263 bytes)
.....
.....
And when I run that from the other system, I get the same output, so I guess it is only when I use the condition "where" with the "TotalItemSize", because I ran the same command but changed the $_.TotalItemSize with $_.ItemCount, and I got a correct result
on both the server and the other computer
Get-Mailbox | Get-MailboxStatistics | where {$_.ItemCount -eq 2} | ft DisplayName, ItemCount, TotalItemSize
This one on the windows 7 client:
DisplayName
ItemCount TotalItemSize
-----------
--------- -------------
Discovery Search Mailbox
2 884 B (884 bytes)
and this on is on the exchange server:
DisplayName
ItemCount TotalItemSize
-----------
--------- -------------
Discovery Search Mailbox
2 884 B (884 bytes)
Regards
Saleh Ramadan
Free Windows Admin Tool Kit Click here and download it now
March 23rd, 2011 3:20pm
Okay, I have the answer. TotalItemSize is not a value, it's an object. Here's the syntax to give you what you want.
Get-Mailbox | Get-MailboxStatistics | where {$_.TotalItemSize.Value.ToMB() -gt 500} | ft DisplayName, ItemCount, TotalItemSize
You could also say ...ToBytes() -gt 500MB.
Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."
March 23rd, 2011 4:42pm
:D
Well, I am getting confused,
On the server this is good and no problems, but when I take it to any other system, something else happen:
PS C:\> Get-Mailbox | Get-MailboxStatistics | where {$_.TotalItemSize.value.tomb() -gt 700} | ft DisplayName, ItemCount,
TotalItemSize
Where-Object : You cannot call a method on a null-valued expression.
At line:1 char:44
+ Get-Mailbox | Get-MailboxStatistics | where <<<< {$_.TotalItemSize.value.tomb() -gt 700} | ft DisplayName, ItemCount
, TotalItemSize
+ CategoryInfo : InvalidOperation: (tomb:String) [Where-Object], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull,Microsoft.PowerShell.Commands.WhereObjectCommand
====
Also doing that like this:
Get-MailboxStatistics -Identity administrator | where {$_.totalitemsize.value.tobytes() -gt 100} | ft DisplayName, ItemCount, TotalItemSize
Fails, and if I remove the "where {....}" it shows good results:
PS C:\> Get-MailboxStatistics -Identity administrator | ft DisplayName, ItemCount, TotalItemSize
DisplayName ItemCount TotalItemSize
----------- --------- -------------
Administrator 10 68.55 KB (70,193 bytes)
Why TotalItemSize returns null values with this command?
When I run the Get-Mailbox | Get-MailboxStatistics it shows correct results from anywhere on the network, when I add that filter, it fail to show anything... And when I do it on any other object such as ItemCount, it shows correct results!
Did you try to run the commands on the exchange server and other computer same as my case? I am curious to know what happened with you actually...
Saleh Ramadan
Free Windows Admin Tool Kit Click here and download it now
March 24th, 2011 3:07am