Okay, I made it one step further.  I had to convert the variable to a
VT_R8 variable.  Now I can't seem to find any documentation on how this
relates to the date.  I guess from here on out it's a Microsoft, not a
Perl question, but I'll post the code I have so far, because I know
others have run into this issue.  At the end I printed out time so that
it was obvious that it was a different time format.  Or maybe I just
have to pack() or unpack() it?  Still researching...

########################################################

use strict;
use warnings;
no warnings qw(uninitialized);
use Win32::OLE qw(in);
use Win32::OLE::Variant;
use Tim::Date_Time;

my @dc = qw(dc1 dc2);
my %users;

foreach my $dc(@dc){
        print "Checking $dc...\n\n";
        my $ADUser = Win32::OLE->GetObject("LDAP://$dc/OU=Groups and
Users,OU=HQ,DC=domain,DC=com") || die;
        foreach(in($ADUser)){
                unless($_->{objectCategory} =~ /Group/i){
                        my $lastlogon =
Win32::OLE::Variant->new(VT_R8,$_->{lastLogon});
                        my $name = $_->{name};
                        print $lastlogon."\n";
                        $name =~ s/^CN=//;
                        push @{$users{$name}},$lastlogon;
                }
        }
}

open(OUTFILE,">lastlogon.csv") || die;
print "Finding last logon...\n";
foreach(sort keys %users){
        my $name = $_;
        print "$name => ";
        my $lastlogon;
        foreach my $logon(@{$users{$_}}){
                print "$logon,";
                if($logon > $lastlogon){
                        $lastlogon = $logon;
                }
        }
        print "($lastlogon)\n";
        $lastlogon = (Date_Time::SimpleDT($lastlogon))[0];
        print OUTFILE "$name,$lastlogon\n";
}
print time;

close OUTFILE;

#########################################################

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to