# ++++++++++++++++++++++++++++++++++++++++++ #NetSessionEnum($server, $client, $user, \@info) #Provides information about all current sessions on server \\testserver. # Specify target computer as first argument (with or without preceding '\\') use Win32::Lanman ; $computer = "$ARGV[0]" ; $sessions_number = 0; $computer = substr($computer,2,) if (substr($computer,0,2) eq "\\\\") ; #print "------------[$computer]------------\n" ; if(!Win32::Lanman::NetSessionEnum("\\\\$computer","", "", \@sessions)) { print "Sorry, something went wrong; error: "; # get the error code print Win32::Lanman::GetLastError(); print " : $^E\n" ; exit 1; } print "\n" ; foreach $session (@sessions) { @keys = keys %$session; if (${$session}{username} ne "") { print ++$sessions_number . "\t" ; foreach $key (@keys) { print " \t$key=${$session}{$key}" . " " x (30 - length(${$session}{$key}))."\n" ; } print "\n" ; } } print "\n" ; # ++++++++++++++++++++++++++++++++++++++++++