Exchange Server 2007 Usage Report
@ Lasse Pettersson, I Indeed appreciate your prompt and valuable response. Thanks keep it up. I will also like to request from a step by step guide on how to become very proficient in scripting. I don't have any scripting/programming background but i want to learn scripting especially for perfoming some basic tasks in window management and on exchange server administration. Your candid advice will be appreciated.
August 13th, 2011 12:26pm

@ Mahendra Mane, You are the bomb! Your script works great! I was wondering if you can tell me what to add/modify on the script to get precise logon time for users. For example say: i want to determine only the users that have logged on to access their boxes in the last so and so hour . I will also like to request from a step by step guide on how to become very proficient in scripting. I don't have any scripting/programming background but i want to learn scripting especially for perfoming some basic tasks in window management and on exchange server administration. Your candid advice will be appreciated.
Free Windows Admin Tool Kit Click here and download it now
August 13th, 2011 12:30pm

Hi forum members, I have an exchange server 2007 plathform that has 10 different accepted domains on it (it accepts emails for 10 different domains- abc.com; xyz.com,opq.net e.t.c). My boss wants a full report of mailbox-enabled users that have actually logged on to the server in the next 48 hours. The report should also contain those that have logged-on earlier than 48 hours and and probably those that haven't logged-on at all. I used Get-mailboxstatistics commandlet but it's not showing me what i really want. I want an output that will display users' smtp addresses (very important) but what am getting is just names all mixed-up. No mean of sorting I will appreciate if i can get the appropriate combination of commadlets that can give me this: Users' SMTP Adddresses; Last Logon date ;Last Logon hour;user that have logged-on in the last 48 hours; users that have never logged-on at all. Somebody please help.
August 13th, 2011 1:35pm

for sorting your list you can use SORT Get-Mailbox | sort -Property DisplayName | Get-MailboxStatistics | ft DisplayName,LastLogonTime this is more effective Get-Mailbox -SortBy DisplayName | Get-MailboxStatistics | ft Displayname,LastLogonTime For output of everything you want on the same line is somewhat tricky, you have to combine several commands and then pipe data you want onto the ssame line. lasse at humandata dot se, http://anewmessagehasarrived.blogspot.com
Free Windows Admin Tool Kit Click here and download it now
August 13th, 2011 6:14pm

Please use the below script to export the details such as DisplayName , Email address , LastLogon Time for all the Mailboxes in the organization. The Script will write the output to a csv file. Copy the below script and save as .PS1. ################################################################################################################################ ################################################################################################################################ ## ## ## Fetch Last Logon Powershell Script : ## ================================= ## ## Author: Mahendra Mane ## Version: 1.0 ## Date: 12 July 2011 ## ## Purpose: Last Logon on Mailboxes ## ## ## ## ## ################################################################################################################################ ################################################################################################################################ ##------------------------------------------------------------------------------------------------------------## $Date=Get-Date $csvfilepath= "C:\Output_{0}{1:d2}{2:d2}-{3:d2}{4:d2}{5:d2}" -f $date.year,$date.month,$date.day,$date.hour,$date.minute,$date.second + ".csv" ################################################################################################################################ # # Function: Logging # # ############################################################################################################################### function logger( $logtext, $logtype ) { switch($logtype) { cINFO { write-host $logtext -b black -f green $logtext | Out-file $Logfilepath -append } cERROR { write-host "ERROR: " $logtext -b black -f red "ERROR: " + $logtext | Out-file $logfilepath -append } csv { write-host $logtext -b black -f green $logtext | Out-file $csvfilepath -append } } } ## ----------------------------------------- End of Function "Logging" --------------------------------------------------------- ######################################################### Script Startup ######################################################## $CsvColumnText= 'Mailbox Name,Email Address,Last Logon' Logger ($CsvColumnText) CSV Get-Mailbox -ResultSize:Unlimited | foreach { $displaytext='' $csvdisplaytext='' $MailboxID = $_.Identity $DisplayName = $_.DisplayName $EmailAddress = $_.WindowsEmailAddress foreach ($Mailbox in $MailboxID) { Get-MailboxStatistics $MailboxID | foreach { $LastLogon = $_.LastLogonTime } } $csvdisplaytext = $DisplayName + ',' + $EmailAddress + ',' + $LastLogon logger ($csvdisplaytext) csv } ########################################################################################################################################################
August 14th, 2011 12:03am

If you want to get precise logon time like users logged in to their mailboxes for the last 1 day you can use the below script. For changing the number of days you need to change the value in "$d.AddDays(-1)" from 1 to the desired value. The output of the script will be saved in a CSV at the location "C:\LastLogontime.csv". $d = get-date $h = $d.get_hour() $m = $d.get_minute() $s = $d.get_second() $d = $d.AddHours(-$h) $d = $d.AddMinutes(-$m) $d = $d.AddSeconds(-$s) $d = $d.AddDays(-1) Get-MailboxServer | Get-Mailbox | foreach-object {$email = $_.primarysmtpaddress; $_ | Get-MailboxStatistics | where-object {$_.LastLogonTime -gt $d -and $_.DisplayName -notlike "*System*"} | select DisplayName, LastLogonTime,@{Name="EmailAddress";expression={$email}}} | Export-CSV "C:\LastLogontime.csv" -notype
Free Windows Admin Tool Kit Click here and download it now
August 14th, 2011 3:51am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics