Returns information about the user accounts found on a computer.

This script was tested using Perl 5.8.0.804 for Microsoft Windows, available from ActiveState.

Perl
Edit|Remove
use Win32::OLE('in');
use constant wbemFlagReturnImmediately => 0x10;
use constant wbemFlagForwardOnly => 0x20;

$computer = ".";
$objWMIService = Win32::OLE->GetObject
    ("winmgmts:\\\\$computer\\root\\CIMV2") or die "WMI connection failed.\n";
$colItems = $objWMIService->ExecQuery
    ("SELECT * FROM Win32_UserAccount","WQL",wbemFlagReturnImmediately | wbemFlagForwardOnly);

foreach my $objItem (in $colItems)
{
      print "Account Type: $objItem->{AccountType}\n";
      print "Caption: $objItem->{Caption}\n";
      print "Description: $objItem->{Description}\n";
      print "Disabled: $objItem->{Disabled}\n";
      print "Domain: $objItem->{Domain}\n";
      print "Full Name: $objItem->{FullName}\n";
      print "Install Date: $objItem->{InstallDate}\n";
      print "Local Account: $objItem->{LocalAccount}\n";
      print "Lockout: $objItem->{Lockout}\n";
      print "Name: $objItem->{Name}\n";
      print "Password Changeable: $objItem->{PasswordChangeable}\n";
      print "Password Expires: $objItem->{PasswordExpires}\n";
      print "Password Required: $objItem->{PasswordRequired}\n";
      print "SID: $objItem->{SID}\n";
      print "SID Type: $objItem->{SIDType}\n";
      print "Status: $objItem->{Status}\n";
      print "\n";
}