Cet exemple de script avec son code permet d'afficher le nom du domaine auquel est joint votre ordinateur dans un domaine Active Directory (sinon le workgroup).
Code du script VBS
' ***************************************************************************************************************
' Affiche le nom du domaine joint sinon le nom du workgroup
' ***************************************************************************************************************
set wshReseau=wscript.createobject("wscript.network")
Set objWMIService = GetObject( "winmgmts:\\.\root\cimv2" )
Set colItems = objWMIService.ExecQuery( "Select * from Win32_ComputerSystem", , 48 )
For Each objItem in colItems
strOrdinateurDomaine = objItem.Domain
If objItem.PartOfDomain Then
WScript.Echo "L'ordinateur " & wshReseau.computername & " est joint au Domaine : " & strOrdinateurDomaine
Else
WScript.Echo "L'ordinateur " & wshReseau.computername & " est dans le Workgroup local : " & strOrdinateurDomaine
End If
Next
' ***************************************************************************************************************