Script Center > Gallery > Security > List Domain Information
TechNet Script Center logo

Welcome to the TechNet Script Center Gallery!

Each contribution is licensed to you under a License Agreement by its owner, not Microsoft. Microsoft does not guarantee the contribution or purport to grant rights to it.

List Domain Information

(Microsoft)
VERIFIED AND TESTED BY THE SCRIPT CENTER TEAM
Rate it:
 
 
 
 
 
Script Code
Perl
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_NTDomain","WQL",wbemFlagReturnImmediately | wbemFlagForwardOnly);

foreach my $objItem (in $colItems)
{
      print "Caption: $objItem->{Caption}\n";
      print "Client Site Name: $objItem->{ClientSiteName}\n";
      print "Creation Class Name: $objItem->{CreationClassName}\n";
      print "Dc Site Name: $objItem->{DcSiteName}\n";
      print "Description: $objItem->{Description}\n";
      print "Dns Forest Name: $objItem->{DnsForestName}\n";
      print "Domain Controller Address: $objItem->{DomainControllerAddress}\n";
      print "Domain Controller Address Type: $objItem->{DomainControllerAddressType}\n";
      print "Domain Controller Name: $objItem->{DomainControllerName}\n";
      print "Domain Guid: $objItem->{DomainGuid}\n";
      print "Domain Name: $objItem->{DomainName}\n";
      print "DS Directory Service Flag: $objItem->{DSDirectoryServiceFlag}\n";
      print "DS Dns Controller Flag: $objItem->{DSDnsControllerFlag}\n";
      print "DS Dns Domain Flag: $objItem->{DSDnsDomainFlag}\n";
      print "DS Dns Forest Flag: $objItem->{DSDnsForestFlag}\n";
      print "DS Global Catalog Flag: $objItem->{DSGlobalCatalogFlag}\n";
      print "DS Kerberos Distribution Center Flag: $objItem->{DSKerberosDistributionCenterFlag}\n";
      print "DS Primary Domain Controller Flag: $objItem->{DSPrimaryDomainControllerFlag}\n";
      print "DS Time Service Flag: $objItem->{DSTimeServiceFlag}\n";
      print "DS Writable Flag: $objItem->{DSWritableFlag}\n";
      print "Install Date: $objItem->{InstallDate}\n";
      print "Name: $objItem->{Name}\n";
      print "Name Format: $objItem->{NameFormat}\n";
      print "Primary Owner Contact: $objItem->{PrimaryOwnerContact}\n";
      print "Primary Owner Name: $objItem->{PrimaryOwnerName}\n";
      print "Roles: " . join(",", (in $objItem->{Roles})) . "\n";
      print "Status: $objItem->{Status}\n";
      print "\n";
}
Platforms
Windows Server 2008 R2 No
Windows Server 2008 No
Windows Server 2003 Yes
Windows 7 No
Windows Vista No
Windows XP Yes
Windows 2000 No
For online peer support, join The Official Scripting Guys Forum! To provide feedback or report bugs in sample scripts, please start a new discussion on the Discussions tab for this script.
Disclaimer The sample scripts are not supported under any Microsoft standard support program or service. The sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.
Be the first to create a discussion.