MadBoy Posted November 8, 2006 Share Posted November 8, 2006 Hello, I've been searching for solution to know if Computer is in Workgroup or Domain and what's Workgroup name or what's Domain Name. I found WMI call that can be used for that but... $Output = $Output & "Domain: " & $objItem.Domain & @CRLF that returns name of Workgroup too. So i thought about checking for @LogonDomain if @logondomain = @computername then you know WMI name it returns is Workgroup. Otherwise it will be domain. But now what if i would like to change that Workgroup to other name? How to do it? And how to do it if i want to join computer to domain (and i would like to do it without netdom.exe)? Any hints? $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output="" $Output = $Output & "Computer: " & $strComputer & @CRLF $Output = $Output & "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $Output = $Output & "Domain: " & $objItem.Domain & @CRLF $Output = $Output & "Workgroup: " & $objItem.Workgroup & @CRLF if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop $Output="" Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_ComputerSystem" ) Endif Func WMIDateStringToDate($dtmDate) Return (StringMid($dtmDate, 5, 2) & "/" & _ StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _ & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2)) EndFunc My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now