I belive if you give LoggedOnUsers an array instead of a hash it just
populates the array with the usernames. So you might not even need to work
with a hash. Check out my script below it should work for you if you have
the proper rights. Oh, and the $host variable needs \\\\ if you want to use
a computername, ie. $host = '\\\\server'.
-Louie
---start of code---
use Win32::NetAdmin;
Win32::NetAdmin::GetDomainController("", $domain, $dc); # Gets primary
domain controller
Win32::NetAdmin::GetUsers($dc,"",\@users); # Gets a list of users from the
pdc
foreach my $user(sort @users){
if($user =~ /\$$/){ #if the username has a $ at
the end it is a
chop $user; #computer so add this to the
system list array
push(@syslist,$user);
}
}
print "Hostname\tUsername\n";
foreach $host (@syslist) { #now we go through each
system
Win32::NetAdmin::LoggedOnUsers($host, \@user); #to find all
the usernames
foreach $user (sort @user) {
#that do not have a $ at the end
if($user !~ /\$$/){
print "$host\t$user\n";
#then we print them out
}
}
}
---end of code---
-----Original Message-----
From: DANIEL SKILES [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 25, 2002 7:59 AM
To: [EMAIL PROTECTED]
Subject: (no subject)
There is a simple way to get the information about users... on to a given
remote
machine if you have Administrator privileges on the remote.
use Win32::NetAdmin;
> Win32::NetAdmin::LoggedOnUsers($hostip, \%userinfo);
> The '%userinfo' hash will contain a hash of all users logged on
> to the remote machine, and the characteristics of the logon. All
> you have to do is select the "Interactive" users and you'll have
> your list. No software will have to run on the remote machine,
> so you don't have to worry about users killing your remote
> processes, or deleting the scripts.
--Thanks for the tip, however, I seem to be running into some issues with
the function. I've tried using the fully scoped name for the LoggedOnUsers
function
as well as hauling it out of the package with qw(LoggedOnUsers). I've tried
using both hostname and IP address to no avail. When I add a die option to
the
LoggedOnUsers function it gives me this error:
No such file or directory at c:\documents and
settings\dskiles\desktop\headcount.pl
Here is the script:
-----------------------
#!c:/perl/bin/perl.exe
use Win32::NetAdmin;
$host = <STDIN>;
Win32::NetAdmin::LoggedOnUsers($host, \%userinfo) ||
die "$!";
------------------------
I've tried entering both the IP and hostname of the student workstation I
want to query. Am I making a stupid newbie mistake or something?
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs