Const domain = "MyDomain" Const laptops = "Laptop Computers" Set objShell = CreateObject("Wscript.Shell") Function IsLaptop() Dim objGroup, retval, cn, objMember cn = objShell.ExpandEnvironmentStrings("%computername%") On Error Resume Next Set objGroup = GetObject("WinNT://" & domain & "/" & laptops & "") If err.Number = 0 Then For each objMember in objGroup.Members If Lcase(objMember.Name) = Lcase(cn & "$") Then retval = True End If Next Else wscript.echo "fail: group not found" End If IsLaptop = retval End Function If IsLaptop() Then wscript.echo "laptop" Else wscript.echo "not-laptop" End If
Thursday, February 3, 2011
Is Computer a Member of a Domain "Laptops" Group
Check if the local computer is a member of a particular AD group that denotes being a laptop:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment