billie_t has asked for the wisdom of the Perl Monks concerning the following question:
if( "" ne $Config{domain} ) { # $Config{machine} = ""; # Win32::NetAdmin::GetDomainController( '', # $Config{domain}, # $Config{machine} ); # Win32::NetAdmin::GetServers( $Config{machine}, # $Config{domain}, # SV_TYPE_DOMAIN_CTRL, # \@MachineList ); @MachineList = qw(SERVER1 SERVER2 SERVER3); }
So, when running the full script, all I get is the results returned for SERVER3. If anyone can shed some light on this, I'd be grateful.#... stuff to populate %accountslist, $account ... foreach my $Machine ( @MachineList ) { ( $Machine = "\\\\$Machine" ) =~ s/^\\+/\\\\/; print "Querying $Machine\n"; foreach my $Account ( sort( keys( %AccountList ) ) ) { my %Attrib; if( Win32::AdminMisc::UserGetMiscAttributes( $Machine, $Account, \%Attrib ) ) { my $Data = $Result{$Account} = {}; $Data->{fullname} = $Attrib{USER_FULL_NAME}; if( $Data->{lastlogon}->{value} < $Attrib{USER_LAST_LOGON} ) { $Data->{lastlogon}->{value} = $Attrib{USER_LAST_LOGON}; $Data->{lastlogon}->{machine} = $Machine; } if( $Data->{lastlogoff}->{value} < $Attrib{USER_LAST_LOGOFF} ) { $Data->{lastlogoff}->{value} = $Attrib{USER_LAST_LOGOFF}; $Data->{lastlogoff}->{machine} = $Machine; } $Data->{badpwcount} += $Attrib{USER_BAD_PW_COUNT}; $Data->{logons} += $Attrib{USER_NUM_LOGONS}; } } } foreach my $Account ( sort( keys( %Result ) ) ) { print "$Account ($Result{$Account}->{fullname}):\n"; print Report( "Last logon", $Result{$Account}->{lastlogon} ), "\n"; print Report( "Last logoff", $Result{$Account}->{lastlogoff} ), "\n" +; print "\tTotal number of bad password attempts: "; print "$Result{$Account}->{badpwcount}\n"; print "\tTotal number of logons: $Result{$Account}->{logons}\n"; print "\n"; } sub Report { my( $Field, $Data ) = @_; my $Date = scalar localtime($Data->{value} ); my $Location = "( $Data->{machine} )"; $Date = "Not available" if( 0 == $Data->{value} ); $Location = "" if( 0 == $Data->{value} ); return( "\t$Field: $Date $Location" ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with ascertaining last NT logon - Roth script
by Roger (Parson) on Feb 17, 2004 at 04:20 UTC | |
by billie_t (Sexton) on Feb 17, 2004 at 06:26 UTC | |
by Roger (Parson) on Feb 17, 2004 at 06:38 UTC | |
by billie_t (Sexton) on Feb 17, 2004 at 08:22 UTC | |
by Roger (Parson) on Feb 17, 2004 at 10:04 UTC | |
|