Solved

Powershell - get-mailboxstats

Posted on 2013-10-23
20
1,035 Views
Last Modified: 2013-10-30
HI Experts,

I'm running powershell commands to pull out lastlogofftime from the mailbox stats, however when running the script:

get-mailbox -resultsize unlimited | get-mailboxstatistics | select DisplayName, LastLogoffTime, LastLoggedOnUserAccount | Export-Csv -Path D:\data\list_lastaccess4th.csv -NoTypeInformation

The output is as follows:
WEB Design             23/10/2013 13:11	DOM\WEBdes
JAMES Jameson        23/10/2013 13:12	DOM\BJC
Christine Bridie       13/09/2013 23:28	DOM\BMCR
Jimmy FLORA		                                DOM\bmf
Shane BENNETT		                        DOM\BSBABC
Laura Davies	        25/06/2012 09:45	DOM\bmb4
Jsaon Cook	        14/05/2013 13:50	DOM\mka
bookings		                                        DOM\RTP
Carmarth	                23/10/2013 12:45	DOM\Carms
YVONNE Jones         10/07/2012 17:35	DOM\mwy1

Open in new window


From the above, there are missing LastLogOffTimes... Although if I query the user manually. The times are there, see below output:

Get-MailboxStatistics bookings | fl

LastLoggedOnUsuerAccount : HQ\RTP
LastLogoffTime          : 23/10/2013 16:55:25
LastLogonTime           : 23/10/2013 16:54:24

Open in new window


Has anyone come across this before?
0
Comment
Question by:MarkMichael
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 8
  • 3
20 Comments
 
LVL 40

Expert Comment

by:Subsun
ID: 39594638
It's probably due to the pipeline bug in EMS.. Try..
$(Foreach ($mailbox in get-mailbox -resultsize unlimited){
$mailbox | get-mailboxstatistics | select DisplayName, LastLogoffTime, LastLoggedOnUserAccount
})| Export-Csv -Path D:\data\list_lastaccess4th.csv -NoTypeInformation

Open in new window

0
 
LVL 52

Expert Comment

by:Manpreet SIngh Khatra
ID: 39594681
Is the Attribute Name correct as its word sensitive and if it doesnt matches the correct word data wont be extracted

- Rancy
0
 
LVL 15

Author Comment

by:MarkMichael
ID: 39594706
Subsun: Same issue unfortunately?

Rancy: The property name is correct, as some of the data is being output for some user accounts but not others. Is that what you mean?
0
Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

 
LVL 40

Expert Comment

by:Subsun
ID: 39594707
@Rancy, If the attribute name is incorrect then it won’t export the value for all the users. The issue is only for specific users..

@MarkMichael, in the report, is the user who miss the log off time is  different from previous report?
0
 
LVL 15

Author Comment

by:MarkMichael
ID: 39596666
Yes, it's different each time.

Sometimes it will return results for person A, B, C and not D.
Another time it will return results for person A, B, D and not C.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39597323
Try this..

$Result = @()
Foreach ($mailbox in get-mailbox -resultsize unlimited){
$Result += get-mailboxstatistics $mailbox.Alias | Select DisplayName,LastLogoffTime,LastLoggedOnUserAccount
}
$Result | Export-Csv -Path D:\data\list_lastaccess4th.csv -NoTypeInformation

Open in new window

0
 
LVL 40

Expert Comment

by:Subsun
ID: 39601309
Did you get a chance to check it?
0
 
LVL 15

Author Comment

by:MarkMichael
ID: 39603199
Sorry, will try in the morning,
0
 
LVL 15

Author Comment

by:MarkMichael
ID: 39603715
Still same issue unfortunately. Still missing random dates in the output.

Thanks for your help so far though.
0
 
LVL 52

Expert Comment

by:Manpreet SIngh Khatra
ID: 39603790
If you have some users not exporting data once check with permissions on those objects, also if you take that single user dump do you get those details ?

- Rancy
0
 
LVL 15

Author Comment

by:MarkMichael
ID: 39603819
Yep, if I just run get-mailboxstatistics mpoole, for example... the data is visible.

Same if I export it to csv, the data is visible in the csv file.
0
 
LVL 52

Expert Comment

by:Manpreet SIngh Khatra
ID: 39604053
can you try to take the data to text and once verify and then work with Excel

- Rancy
0
 
LVL 15

Author Comment

by:MarkMichael
ID: 39604512
verified:

"DisplayName","LastLogoffTime","LastLoggedOnUserAccount"
"Poole",,"DOMAIN\Poole"

Missing LastLogoffTime

I get the same, when I send the output to screen too, I can see several users missing the same fields, but they appear when I view them one by one.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39605493
Can you try to run the same script from a different server?
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39605503
Also try...
Get-mailboxserver | get-mailboxstatistics | select DisplayName, LastLogoffTime, LastLoggedOnUserAccount | Export-Csv -Path D:\data\list_lastaccess4th.csv -NoTypeInformation

Open in new window

0
 
LVL 15

Author Comment

by:MarkMichael
ID: 39605533
Same with both tests, sorry.

Still the same outputs.

I even ran the script from an exchange server in another AD site, same issue.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39605556
Sorry.. I cannot reproduce your issue...  Even I have some accounts which miss LastLogoffTime but they also didn't output LastLogoffTime when I run get-mailboxstatistics directly for that account.

Which service pack level and RU you have?
0
 
LVL 15

Author Comment

by:MarkMichael
ID: 39606240
Still stuck on SP1 currently, customer is slow at approving updates!

On the other hand, I've just ran the same scripts on another customer Exchange server who has SP3 installed. Same issue!

There doesn't seem to be any pattern with the output though. Very very odd.
0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 39611419
Hmm... Does this make any difference?
$Server = Get-mailboxserver
$Server | % {get-mailboxstatistics -Server $_.Name | select DisplayName, LastLogoffTime, LastLoggedOnUserAccount} | Export-Csv -Path D:\data\list_lastaccess4th.csv -NoTypeInformation

Open in new window

or
$Servers = Get-mailboxserver
$ReSult = @()
Foreach ($Server in $Servers){
$ReSult += Get-mailboxstatistics -Server $Server.Name | select DisplayName,LastLogoffTime,LastLoggedOnUserAccount
}
$ReSult | Export-Csv -Path D:\data\list_lastaccess4th.csv -NoTypeInformation

Open in new window

0
 
LVL 15

Author Comment

by:MarkMichael
ID: 39611458
1st one seems to work! Well done :)

Thanks for persisting through this with me!
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A list of top three free exchange EDB viewers that helps the user to extract a mailbox from an unmounted .edb file and get a clear preview of all emails & other items with just a single click on mailboxes.
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
how to add IIS SMTP to handle application/Scanner relays into office 365.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question