Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET

vbscript to write to AD department field for multipe users

Home Forums Scripting Windows Script Host vbscript to write to AD department field for multipe users

Viewing 1 post (of 1 total)
  • Author
    Posts

  • Goozer16
    Member
    #167725

    Hi there. I am new to vbscript and I already have been advised to change this script to Powershell, but I must make this work as I’ve inherited this not working script.

    This script looks to a group in AD, and if users are in that (security) group, then proceeds to change the department variable on users in designated sections in our organization, base on their memberships in those section’s security groups. It is not working and I need to get it working…

    {

    On Error Resume Next

    Set objGroup = GetObject _
    (“LDAP://CN=livetimecustomers,OU=service accounts,DC=domain,DC=com”)
    ‘ WScript.Echo objGroup.Name

    For Each objMember In objGroup.Members
    ‘ WScript.Echo vbCrlf & ” Name: ” & objMember.Name
    arrGroups = objMember.GetEx(“member”)
    If (Err.Number = 0) Then
    On Error GoTo 0
    strGroups = LCase(Join(arrGroups))

    ‘ Update Department attribute for COMMUNITY members

    If InStr(strGroups, “cn=community,ou=community,dc=domain,dc=com”) Then
    ‘ WScript.Echo vbCrlf & ” Name: ” & objMember.Name & ” is member of COMMUNITY”
    Set objUser = GetObject(objMember.ADsPath)
    objUser.department = “COMMUNITY”
    objUser.SetInfo
    End If

    ‘ Update Department attribute for ARTS members

    If InStr(strGroups, “cn=arts,ou=arts,ou,dc=domain,dc=com”) Then
    ‘ WScript.Echo vbCrlf & ” Name: ” & objMember.Name & ” is member of ARTS”
    Set objUser = GetObject(objMember.ADsPath)
    objUser.department = “ARTS”
    objUser.SetInfo
    End If

    }

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

Live Webinar: Active Directory Security: What Needs Immediate Priority!Live on Tuesday, October 12th at 1 PM ET

Attacks on Active Directory are at an all-time high. Companies that are not taking heed are being punished, both monetarily and with loss of production.

In this webinar, you will learn:

  • How to prioritize vulnerability management
  • What attackers are leveraging to breach organizations
  • Where Active Directory security needs immediate attention
  • Overall strategy to secure your environment and keep it secured

Sponsored by: