Partager via


Find domain membership via WMI

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