here a simple script to get the user last logon information for Exchange 2003 and Exchange 2010:
Exchange 2003:
#$erroractionpreference = "SilentlyContinue"
$user=Import-CSV "c:\serviceMBX.csv"
$report="c:\\ReportSvcMBXLastLogon.csv"
Clear-Content $report
add-content $report "Handle,MailboxDisplayName,LoggedOnUserAccount,LogonTime,ClientMode,ClientVersion,ServerName"
foreach ($usr in $user)
{
$identity= $usr.handle
$script=get-mailbox -identity $identity | select-object legacyExchangeDN,servername
if($error.count -gt 0){
$string ="User " + $identity + " doesn't exist in AD"
add-content $report -VALUE $string
write-host "User " $identity " doesn't exist in AD"
$error.clear()
}
else
{
foreach ($u in $script)
{
$legDN=$u.legacyExchangeDN
$serverEx=$u.servername
$lastL=get-wmiobject -class Exchange_logon -Namespace "root\MicrosoftexchangeV2" -Computer $serverEx -Filter "MailboxLegacyDN='$legDN'"|select-object MailboxDisplayName,LoggedOnUserAccount,LogonTime,ClientMode,ClientVersion,ServerName
write-host $legDN
write-host $serverEx
write-host $identity
foreach ($2k3 in $lastL) {
$displN=$2k3.MailboxDisplayName
$LOnUser=$2k3.LoggedOnUserAccount
if ($2k3.LogonTime -ne $null) {
$LOnTime=[System.Management.ManagementDateTimeConverter]::ToDateTime($2k3.LogonTime)
}else{
$LOnTime=$2k3.LogonTime
}
$cliMode=$2k3.ClientMode
$cliVer=$2k3.ClientVersion
}
}}
$string=$identity + "," + $displN + "," + $LOnUser + "," + $LOnTime + "," + $cliMode + "," + $cliVer + "," +$serverEx
add-content $report -VALUE $string
}
###### end code
Client Mode:
1=classic
2=Cached
Client Version:
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.