Listing20_Trigger_KCC_IadsTools (Perl)

This code can be found in Chapter 9 of Managing Enterprise Active Directory Services

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the Perl code from this site.

# From the book "Managing Enterprise Active Directory Services"
# ISBN: 0-672-32125-4

use strict;
use Win32::OLE;

# DC to trigger KCC on
my $dc = 'dc1';

# Authentication information
my $user   = 'administrator';
my $passwd = 'password';
my $domain = 'XYZ';

my $i = Win32::OLE->new("IADsTools.DCFunctions");
my $res = $i->SetUserCredentials($user,$domain,"",$passwd);
die "Authentication failed in SetUserCredentials\n" if $res != 0;

my $res = $i->TriggerKCC($dc,1);
if ($res != 0) {
   print "Failed to trigger KCC on $dc\n";
}
else {
   print "KCC triggered on $dc\n";
}

This code has been viewed 618 times.

New from the creators of TechTasks.com: StatSheet.com