saghilar said:
i have to check the migration of my 450 pc's from a domain to another.
The first step I'm doing it's to migrate the pc account from domain1
to domain2, so i have to check the domain of every pc.
I know that I can check the %userdomain% but i can find any system
variable for 'pc domain'.
anyone have some ideas?
Hi,
Parse the output from "net.exe config workstation" in a batch file, or
use VBScript/WMI.
Batch file (do *not* remove the spaces in "workstation domain "):
'--------------------8<----------------------
@echo off
for /f "tokens=3" %%a in (
'net.exe config workstation^|find.exe /i "workstation domain "') do set domain=%%a
echo %domain%
'--------------------8<----------------------
VBScript/WMI:
'--------------------8<----------------------
sNode = "." ' use "." for local computer
Set oWMI = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & sNode & "\root\cimv2")
Set colComputer = oWMI.ExecQuery _
("Select DomainRole, Domain from Win32_ComputerSystem")
For Each oComputer in colComputer
iDR = oComputer.DomainRole
sName = oComputer.Domain
Next
If iDR = 0 Or iDR = 2 Then
WScript.Echo "Computer is in workgroup " & sName
Else
WScript.Echo "Computer is in domain " & sName
End If
'--------------------8<----------------------