Is there way to have it query all domain controllers in the domain? I was thinking of modifying it to run the script as a subroutine and use lanman or netadmin to loop it through all the DC's. The problem is if you have more then one DC you wont get accurate results. It needs to be run on each one. I was thinking of having it run as a sub, hit each one, dump the info into a text file and then use excel to clean it up. Does anyone know how to implement that easily or think that is the best way to do it? Thx, Leon -----Original Message----- From: Tim Dumas [mailto:[EMAIL PROTECTED] Sent: Thursday, June 12, 2003 2:00 PM To: 'Leon'; 'Tillman, James'; 'Robert-Jan Mora' Cc: 'perl'; 'win32'; 'Yahoo Beginner Perl' Subject: RE: Last Logon of ALL users in the domain If you want the Time of logon along with the date you can use this modified version. use Win32::OLE; use Win32::OLE::Variant; use Win32::OLE::NLS qw(:LOCALE :DATE); my $domain = Win32::OLE->GetObject("WinNT://DomainHere"); foreach my $object (in $domain) { if ($object->{Class} eq 'User') { my $last_login; if ($object->{LastLogin}) { $last_login_date = $object->{LastLogin}->Date(DATE_LONGDATE); $last_login_time = $object->{LastLogin}->Time(); }else { $last_login_date = "Unknown"; $last_login_time = "Unknown"; } print $object->{Name} .. "=" . $last_login_date . " " . $last_login_time ."\n"; } } Tim Dumas -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Leon Sent: Thursday, June 12, 2003 12:03 PM To: Tillman, James; Robert-Jan Mora Cc: perl; win32; Yahoo Beginner Perl Subject: RE: Last Logon of ALL users in the domain This totally 100 percent worked. Thank you so much!!!!
"Tillman, James" <[EMAIL PROTECTED]> wrote: This works on my own domain from a Win2k or NT box: use Win32::OLE; use Win32::OLE::Variant; use Win32::OLE::NLS qw(:LOCALE :DATE); my $domain = Win32::OLE->GetObject("WinNT://IRM-NT"); foreach my $object (in $domain) { if ($object->{Class} eq 'User') { my $last_login; if ($object->{LastLogin}) { $last_login = $object->{LastLogin}->Date(DATE_LONGDATE) } else { $last_login = "Unknown"; } print $object->{Name} .. "=" . $last_login . "\n" } } Just a thought... jpt INDEPENDENCE COMMUNITY BANK CONFIDENTIALITY NOTICE: This message (and any attachment) is confidential and intended for the sole use of the individual or entity to which it is addressed. If you are not the intended recipient, you must not review, retransmit, convert to hard-copy, copy, use or disseminate this email or any of its attachments. If you received this email in error, please notify the sender immediately and delete it. This notice is automatically appended to all Internet email.