Access logon (Perl)
This code can be found in
Chapter 5 of Exchange Server Cookbook
Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.
Find out how to download all of the Perl code from this site.
# This script was originally published in the Exchange Cookbook,
# (http://www.exchangebookcook.com). Written by Paul Robichaux,
# Missy Koslosky, and Devin Ganger. Redistributed with permission
# of the publisher, O'Reilly & Associates.
# ------ SCRIPT CONFIGURATION ------
use Win32::OLE qw(in);
use constant vbCrLf => "\r\n";
$strComputerName = '<serverName>';
# e.g. "batman"
# ------ END CONFIGURATION ---------
$strE2K3WMIQuery = 'winmgmts://' . $strComputerName . '/root/MicrosoftExchangeV2';
# Find each mailbox on the target server. Get the last logon date and user.
# Display them all.
$mboxList = Win32::OLE->GetObject('Exchange_Mailbox');
foreach my $mailbox (in $mboxList) {
$strOutput = '';
$strOutput = 'Mailbox: ' . $mailbox->MailboxDisplayName . vbCrLf;
$theTime = $mailbox->LastLogonTime;
if ((!($theTime))) {
$strOutput = $strOutput . ' Never logged on' . vbCrLf;
}
else {
$strOutput = $strOutput . ' Last logon at: ' . $theTime . vbCrLf;
$strOutput = $strOutput . ' by: ' . $mailbox->LastLoggedOnUserAccount;
}
print "$strOutput\n";
}
|
This code has been viewed 1042 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|