You've got the right function, but machine accounts are not listed in the SAM as \\\\$PC_name Try replacing that with "$PC_name\$".  If you do a dump of all users using NetAdmin, you should see a bunch of accounts that look like this:  COMPUTERNAME$,SERVER1$,SERVER2$, etc.
 
-----Original Message-----
From: c.barbet [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 27, 2002 1:42 PM
To: [EMAIL PROTECTED]
Subject: Fw: Removing machine accounts

-resent as I was unaware I was sending to an incorrect list previously-
 
Good Day All,
 
I've been searching around for the proper syntax to remove a machine account from a Windows Domain.  Here is the code I believe should accomplish that task: (I've also tried the domain controller name in lieu of DOMAINNAME)
---------
use strict;
use Win32::NetAdmin;
 
my $PC_name = shift;
 
if (Win32::NetAdmin::UserDelete("\\\\DOMAINNAME", "\\\\$PC_name")) {
    print "$PC_name has been removed.";
} else {
    print "No such account $PC_name.";
}
--------
 
Am I using the correct module and function?  I see no MachineDelete function in NetAdmin.  Is this even the appropriate module?  Thanks in advance for any direction provided.  As one may have guessed, I am rather new to perl.
 
Regards,
c.barbet
 

Reply via email to