Archive for October, 2008

How to list domain information using VBScript – WMI?

October 31, 2008

Here is a handy VBScript code to list domain information. This code will list down the domain information for all the domains found on that machine.

on Error Resume Next
strComputer = “.”
Set objWMISvc = GetObject (“winmdmts:”_
& “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”)
Set colItems = objWMISvc.ExecQuery(“Select * from Win32_NTDomain”)
For Each objItem in colItems
Wscript.Echo “Client Site Name: ” & objItem.ClientSiteName
Wscript.Echo “DC Site Name: ” & objItem.DCSiteName
Wscript.Echo “Descriptopn: ” & objItem.Description
Wscript.Echo “DNS Forest Name: ” & objItem.DnsForestName
Wscript.Echo “Domain Controller Address: ” & objItem.DomainControllerAddress
Wscript.Echo “Domain Controller Address Type: ” & objItem.DomainControllerAddressType
Wscript.Echo “Domain Controller Name: ” & objItem.DomainControllerName
Wscript.Echo “Domain GUID: ” & objItem.DomainGuid
Wscript.Echo “Domain Name: ” & objItem.DomainName
Wscript.Echo “Primary Owner Contact: ” & objItem.PrimaryOwnerContact
Next

Hope this Helps!

This blog will be closed in near future, please refer the same article at : http://aparajit.co.in/blogs/sandeep/archive/2008/10/31/how-to-list-domain-information-using-vbscript-wmi.aspx