Thursday, September 18, 2008

Logon Statistic Shell

this post has been moved to
http://www.exchange-genie.com/2008/09/logon-statistic-shell/

9 comments:

Alec Istomin said...

Is there a reason script is provided as a screen shot? Posting images makes sure nobody will be able to try this out easily :)

Exchange_Genie said...

my apoloiges, I was doing it from work and the blogger always drops some of the character unless I edit the html so I thought it was easier to add a jpg. There is no option to add a file to download or I would have done it that way.
I will post the code but check the syntax because the system removes some characters

Shay Levy said...

Hi Genie

I would skip the get-mailbox call and start directly with Get-MailboxStatistics :

$data = Get-MailboxStatistics | where { ($_.lastLogonTime -gt $date) -and ($_.objectClass -notmatch 'ExOleDbSystemMailbox')}


-Shay

Exchange_Genie said...

First good call to add the skip system mailboxes.....

you can however Get-MailboxStatistics will only run agaist the local server. so if only have 1 then you are ok, however for large multi server environmnets adding the get-mailbox will get all the mailboxes.

http://technet.microsoft.com/en-us/library/bb124612.aspx

Shay Levy said...

You're right :-), it won't work for multi server environmnets, but you can work it out. I found two ways:


1. Put the servers name in a csv file, import it and pipe it to Get-MailboxStatistics, A sample file will look like:

## c:\exServers.csv ##
server
ex1
ex2

PS > import-csv c:\exServers.csv | Get-MailboxStatistics

2. Cast the servers name to a ServerIdParameter and then pipe to Get-MailboxStatistics:

PS > [Microsoft.Exchange.Configuration.Tasks.ServerIdParameter[]]("ex1","ex2") | Get-MailboxStatistics


-Shay

Exchange_Genie said...

lots of ways to do it, whatever works for you... you can have it read in input for the servers etc...
I like to set all mbx's to the variable and then I can call it again to get other data with out the additioanl query overhead..

i.e I have a script that checks how many users use active sync or iphone etc.... I could combine them but only do 1 query.

Nature's Revenge said...

You can always screenshot the jpg using OneNote and then capture text out of said jpg. :)

Shay Levy said...

It seems I took the long path for no reason, to get mailbox statistics in large multi server environmnets one can simply do:

PS > Get-MailboxServer | Get-MailboxStatistic


-Shay

Exchange_Genie said...

gotta love the piping :)