Create custom group policy settings (Misc)

This code can be found in Chapter 10 of Active Directory Cookbook, 2nd edition

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

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

# This Perl code displays all of the GPOs for a domain.

# ---------------------------------------------------------------
# Adapted from VBScript code contained in the book:
#      "Active Directory Cookbook" by Robbie Allen
# ISBN: 0-596-00466-4
# ---------------------------------------------------------------

# ------ SCRIPT CONFIGURATION ------
my $strDomain   = "<DomainDNSName>";   # e.g. rallencorp.com
# ------ END CONFIGURATION ---------
use Win32::OLE 'in';
$Win32::OLE::Warn = 3;
my $objGPM = Win32::OLE->CreateObject("GPMgmt.GPM");
my $objGPMConstants = $objGPM->GetConstants();
  
# Initialize the Domain $object
my $objGPMDomain = $objGPM->GetDomain($strDomain, "", $objGPMConstants->UseAnyDC);

# Create an empty search criteria
my $objGPMSearchCriteria = $objGPM->CreateSearchCriteria;
my $objGPOList = $objGPMDomain->SearchGPOs($objGPMSearchCriteria);

# Print the GPOs.
print "Found ", $objGPOList->Count," GPOs in ", $strDomain, ":\n";
foreach my $objGPO (in $objGPOList) {
   print "   ", $objGPO->DisplayName,"\n";
}

This code has been viewed 3105 times.

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