Find domain membership via WMI

Find domain membership via WMI

Rate This
  • Comments 0

Here’s a quick and dirty VBScript to find the domain of a certain computer. Great for things like SCCM OS Deployment.

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colSettings
Wscript.Echo "Domain: " & objComputer.Domain
Next

Matt Shadbolt

Leave a Comment
  • Please add 4 and 8 and type the answer here:
  • Post