Announcement

Collapse
No announcement yet.

verify computers domain membership

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • verify computers domain membership

    Does anyone have a script or can anyone help me with writing a script that will basically query a computer/server to see either what domain it is a member of or if it in a workgroup. Ideally taking input by reading server names out of a excel file or a textfile and dumping the information back into a file (same or different)

    gratz!!

  • #2
    Re: verify computers domain membership

    Hi,

    Here is something to get you started if you don't get the full solution from somewhere else:

    Code:
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
    Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
    For Each objItem In colItems
      WScript.Echo "Computer Name: " & objItem.Name
      WScript.Echo "Name Format: " & objItem.NameFormat
      WScript.Echo "Domain: " & objItem.Domain
      WScript.Echo "Part Of Domain: " & objItem.PartOfDomain 'post-Windows 2000 only
      WScript.Echo "Workgroup: " & objItem.Workgroup 'post-Windows 2000 only
      Select Case objItem.DomainRole
        Case 0 strDomainRole = "Standalone Workstation"
        Case 1 strDomainRole = "Member Workstation"
        Case 2 strDomainRole = "Standalone Server"
        Case 3 strDomainRole = "Member Server"
        Case 4 strDomainRole = "Backup Domain Controller"
        Case 5 strDomainRole = "Primary Domain Controller"
      End Select
      WScript.Echo "Domain Role: " & strDomainRole
      strRoles = Join(objItem.Roles, ",")
      WScript.Echo "Roles: " & strRoles
      WScript.Echo "Network Server Mode Enabled: " & _
       objItem.NetworkServerModeEnabled
    Next
    Ref: http://www.microsoft.com/technet/scr....mspx?mfr=true

    However this script is just basic and It won't read from a text file and the output is just a message box (Wscript.echo).

    Maybe one of the scripting Gurus here can trim it and add to it.

    Ta
    Caesar's cipher - 3

    ZKHQ BRX HYHQWXDOOB GHFLSKHU WKLV BRX ZLOO UHDOLVH LW ZDV D ZDVWH RI WLPH!

    SFX JNRS FC U6 MNGR

    Comment


    • #3
      Re: verify computers domain membership

      gratz for the script. now if only I can get it to read from a file and post the output to a file ... life would be just peachy !!

      Comment

      Working...
      X