Announcement

Collapse
No announcement yet.

VBS Mismatch Join

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

  • VBS Mismatch Join

    I 'did' a search for this and found some interesting answers but they don't 'seem' to apply in my case. I'm running a 2003 AD Domain in the process of migrating to a new domain. On the new domain we will use VBS scripts that I have written and tested from both domains. The script works for most of the users but I ran across a user that gets a "Type Mismatch Join' error for line 70 -- the last statement in the following code is line 70. This user is one of the generic users that we have in the plant but the script works for other generic users.

    This user is local administrator of the machine, and belongs to 2 groups in AD -- those were the 2 suggestions I found on the forum. The other users that this script works for are not network administrators - only local admins of their machine.

    All the mapping runs up to this point just as it should.
    any suggestions would be appreciated. I'm very new to VBS scripting and a lot of the script was cut/paste from a script used for OUs already in this new domain.
    Set ADSysInfo = CreateObject("ADSystemInfo")
    Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
    strGroups = LCase(Join(CurrentUser.MemberOf))

    Thanks,
    Mary

  • #2
    Re: VBS Mismatch Join

    "Join" expects a one-dimensional array of strings.

    I believe "MemberOf" returns a "collection" that one would normally enumerate in a "For Each" statement.

    Have you tried a "For Each" statement that concatenates all members of the collection into a single string?
    Cheers,

    Rick

    ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

    2006-2099 R Valstar. This post is offered "as is" for discussion purposes only with no express or implied warranty of any kind including, but not limited to, correctness or fitness for use. Nothing herein shall be construed as advice. Attempting any activity based on information in this post is done at your own risk.

    Comment


    • #3
      Re: VBS Mismatch Join

      no - I haven't tried that - I will try. I've been trying to focus more on why this script works for the majority and fails for a few others and fix that area.

      here's the entire script - the group membership section hasn't worked so I've commented them out to work on at a later date. All the drive mappings work (except for the U drive) with the failure being the line above that function.

      The line that is failing - is that only used for the group mappings? I'll comment that out and see if the script will run.

      ******************************

      Option Explicit

      'Const ict = "cn=groupname"

      Dim WshNetwork, oDrives, i, ADSysInfo, CurrentUser, strGroups, objShell

      Set WshNetwork = WScript.CreateObject("WScript.Network")
      Set oDrives = WshNetwork.EnumNetworkDrives
      Set objShell = Wscript.CreateObject("Wscript.Shell")

      '###################################
      'sets time to edn01dc at the time of login
      '###################################

      objShell.Run ("%comspec% /c NET TIME \\edn01dc /SET /Y"), 0, False


      '###########################################
      'EnumNetworkDrives returns a collection of the current network drive mappings
      '###########################################

      DriveMapper "G:", "\\X\X"
      DriveMapper "H:", "\\X\X"
      DriveMapper "I:", "\\X\X"
      DriveMapper "J:", "\\X\X"
      DriveMapper "K:", "\\X\X"
      DriveMapper "R:", "\\X\X"
      DriveMapper "U:", "\\X\X"


      '############################################
      'subroutine that removes network drives if present
      ' RemoveNetworkDrive method removes a previously mapped network drive
      '############################################

      Sub DriveMapper(Drive, Share)
      For i = 0 To oDrives.Count -1 Step 2
      If LCase(Drive) = LCase(oDrives.Item(i)) Then
      If Not LCase(Share) = LCase(oDrives.Item(i+1)) Then
      WshNetwork.RemoveNetworkDrive Drive, True, True
      Else
      Exit Sub
      End If
      End If

      Next
      End Sub


      '############################################
      ' MapNetworkDrive subroutine that adds network drives ~ maps a remote drive onto a local drive letter
      '############################################

      Set wshNetwork = CreateObject("WScript.Network")

      wshNetwork.MapNetworkDrive "G:", "\\edn01dc\Apps"
      wshNetwork.MapNetworkDrive "H:", "\\edn01dc\Data"
      wshNetwork.MapNetworkDrive "I:", "\\edn01dc\Iso"
      wshNetwork.MapNetworkDrive "J:", "\\edn01dc\Global"
      wshNetwork.MapNetworkDrive "K:", "\\edn01dc\Read_Only"
      wshNetwork.MapNetworkDrive "R:", "\\edn01dc\Share"


      Set ADSysInfo = CreateObject("ADSystemInfo")
      Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
      strGroups = LCase(Join(CurrentUser.MemberOf))


      '###########################################
      'use this function to map a network drive to the UserName
      '############################################

      Dim objNetwork
      Dim strDriveLetter, strRemotePath, strUserName
      strDriveLetter = "U:"
      strRemotePath = "\\Edn01dc\home"

      Set objNetwork = WScript.CreateObject("WScript.Network")

      strUserName = objNetwork.UserName
      objNetwork.MapNetworkDrive strDriveLetter, strRemotePath & "\" & strUserName


      '########################################
      'group similar groups together and use the OR logical operator
      '########################################
      'If InStr(strGroups, Groupname) OR InStr(strGroups, Groupname) Then

      ' wshNetwork.MapNetworkDrive "F:", "\\server\share"

      'End If

      'If InStr(strGroups, "ict") Then

      ' wshNetwork.MapNetworkDrive "J:", "\\server\share"

      'End If

      Comment


      • #4
        Re: VBS Mismatch Join

        Commenting out the line
        'strGroups = LCase(Join(CurrentUser.MemberOf))

        let the script run without the Mismatch Join error.

        Now that the script is running for everyone (at least for now) I can spend some time on getting mappings for users in specific groups to work.

        I didn't write that section and I've seen other ways to map all the users in a group to a specific drive that I'll have to investigate.
        Any suggestions?

        thanks so much for the suggestion of the "For Each' or I'd never have looked close enough to the script to see the strGroups.

        Mary

        Comment


        • #5
          Re: VBS Mismatch Join

          Glad it got you functional for now.
          Cheers,

          Rick

          ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

          2006-2099 R Valstar. This post is offered "as is" for discussion purposes only with no express or implied warranty of any kind including, but not limited to, correctness or fitness for use. Nothing herein shall be construed as advice. Attempting any activity based on information in this post is done at your own risk.

          Comment

          Working...
          X