Title: Enumerate Win2K Profiles

Is there a way to remotely obtain information on what profiles are on a Windows2000 computer? I am not referring to User Accounts in a domain.

I was looking at using WMI per the following code. In WMI, I want to retrieve both the Domain and Name, or "Caption" which contains both of these; additionally, it would be an advantage to determine the last time that account logged onto that particular machine.  Note: the computer in this snippet is the one I am currently logged onto; I am an Administrator of that computer and a member of Administrator's on all of the target computers.

======Start Code Snippet======
use Win32::OLE qw( in );
$Server = 'vdymj_2';
$result = CheckProfile( $Server );

sub CheckProfile{
        my ( $Server, @junk ) = @_;
        my $Path = "WinMgmts://$Server";
        my $WMI = Win32::OLE->GetObject( $Path );
        if ( ! $WMI ) {
                return;
        }else{
                foreach my $item ( in( $WMI->InstancesOf( 'Win32_UserAccount' ) ) ) {
                        print "\t\$item = $item\n";
                        $domain = $item->{Domain};
                        $name = $item->{Name};
                        print "\tDom: $domain     Name: $name\n\n";
                }
                return;
        }
}
======End Code Snippet======

This does indicate that $item is a hashref, but I have not been able to grab any of the information we need. I have tried variations, such as:

      $domain = $item->{Domain}->{Value}; 
without success.

I have also tried the following after creating the $WMI object, but it just hangs, not printing anything out:

                $list = $WMI->ExecQuery("select * from Win32_UserAccount");
                print "\$list = $list\n\n";
                foreach (key %$list ) {
                        print "$_\n";
                }

I appreciate any assistance or advice.

Sam F. Crosby
NT Administration
EMail Direct: [EMAIL PROTECTED]


Reply via email to