+ Post New Thread
Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19
Scripts Thread, Script to install program based on AD group in Coding and Web Development; Code: Dim objNetwork Set objNetwork = CreateObject("WScript.Network") Dim objWinntComp Set objWinntComp = GetObject("WinNT://" & objNetwork.UserDomain & "/" & objNetwork.ComputerName & ...
  1. #16

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,729
    Thank Post
    3,252
    Thanked 1,049 Times in 971 Posts
    Rep Power
    364
    Code:
    Dim objNetwork
    Set objNetwork = CreateObject("WScript.Network")
    
    Dim objWinntComp
    Set objWinntComp = GetObject("WinNT://" & objNetwork.UserDomain & "/" & objNetwork.ComputerName & ",computer")
    MsgBox "WinNT://" & objNetwork.UserDomain & "/" & objNetwork.ComputerName & ",computer"
    
    Dim strGroupToCheck
    strGroupToCheck = "Jack_grp"
    
    If IsMemberOfGroup(objNetwork.UserDomain, objWinntComp, strGroupToCheck) = True Then
          MsgBox "You are a member of " & strGroupToCheck
    ElseIf IsMemberOfGroup(objNetwork.UserDomain, objWinntComp, strGroupToCheck) = False Then
          MsgBox "You are NOT a member of " & strGroupToCheck
          WScript.Quit
    ElseIf IsMemberOfGroup(objNetwork.UserDomain, objWinntComp, strGroupToCheck) = "Error" Then
          MsgBox "There was no group found called " & strGroupToCheck
          WScript.Quit
    End If      
    
    Function IsMemberOfGroup(strUserDomain, objComp, strGroup) 'the user is a member of a specified group
          IsMemberOfGroup = False
          Dim objGroup
          On Error Resume Next
          Set objGroup = GetObject("WinNT://" & strUserDomain & "/" & strGroup & ",group")
          If Err.Number Then
                IsMemberOfGroup = "Error"
          Else
                IsMemberOfGroup = objGroup.IsMember(objComp.ADsPath & "$")
          End If
    End Function
    Determine computer group membership in VBScript : group, computer, vbscript, membership, determine

    Also

    Checking Group Membership in VBScript - CyrusBuilt dot Net

  2. #17


    Join Date
    Feb 2007
    Location
    51.405546, -0.510212
    Posts
    8,778
    Thank Post
    223
    Thanked 2,633 Times in 1,940 Posts
    Rep Power
    780
    Could you do something like this in PowerShell, but instead of running "dir" on each computer remotely, you use the Test-Path cmdlet to check if a file/folder/registry key exists and then Start-Process to execute your installer with the relevant parameters?

    Code:
    if(!(Get-Module | Where { $_.name -eq "ActiveDirectory" })) {
        Import-Module ActiveDirectory -ErrorAction 0 | Out-Null
    }
    
    Invoke-Command -Command { dir } -ComputerName ( Get-ADGroupMember "Example App v1.0" -recursive | Select-Object -expand Name ) -ThrottleLimit 32 -ErrorAction SilentlyContinue

  3. #18

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,802
    Thank Post
    272
    Thanked 1,135 Times in 1,031 Posts
    Rep Power
    349
    Quote Originally Posted by glennda View Post
    Can you not setup in gpo so that it only applies if machines are in a group like you can with users?
    ah ok i didn't read the thread!

  4. #19

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,852
    Thank Post
    877
    Thanked 1,681 Times in 1,460 Posts
    Blog Entries
    12
    Rep Power
    445
    Thanks i will have a play about. I dont think i will be good enough to master this on my own though. I will give it a shot and see what happens.

SHARE:
+ Post New Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 24
    Last Post: 16th July 2013, 10:33 AM
  2. Replies: 9
    Last Post: 6th October 2010, 03:54 PM
  3. Script to call another based on machine name
    By originofsymmetry in forum Scripts
    Replies: 5
    Last Post: 2nd May 2008, 12:04 PM
  4. Replies: 4
    Last Post: 23rd November 2006, 09:33 PM
  5. Script to change user email in AD (or Exchange)
    By SpuffMonkey in forum Scripts
    Replies: 16
    Last Post: 8th November 2005, 10:31 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •