Announcement

Collapse
No announcement yet.

Mapping drives automatically to different servers.

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

  • Mapping drives automatically to different servers.

    Is is possible to create a GPO or log in script or something that will map drives depending on what server you log into?

    Our small company is quickly growing, we are finishing up the setup for our first remote office. We have 2-2012R2 DCs at the main office and one at the remote office. We have a VPN connection for the servers between the offices. There will be a couple of floater users and a couple of permant users at the remote location. We have files that are modified daily, most are large. Those are going to be setup with DFS. We also have files that are mainly reference files and are mainly viewed rarely modified. I am pretty new to GPOs, I believe I have a basic understanding and have been playing around with some simple ones. I didn't know if there was a way to have it so if a user logs into the main office server it maps the [Jobs] drive to that server, if the user were to go to the remote office and log in the mapped [Jobs] drive will automatically point to that server. This will prevent the user trying to access the large files directly over the VPN and let the DFS handle the changes.

    I'm pretty sure this can be done, I'm just sure if it's one of those things where It can be done but it's complicated and probably not worth the trouble. Worst case is that I rename the maps and they will have to make sure they open the right ones for their location.

    Thanks for any info.

  • #2
    The only thing I can think of (and this is something I've not needed to do), is to set up a batch file to run at user logon. The batch file can determine the server the user has logged onto by querying the logonserver environment variable. So you could have a line stating If %logonserver% == servername goto servername. You can then have the appropriate drive mapping commands under :servername

    I have not fiddled with batch files for a long time so you will need to read up on the use of the If command etc., if you need to.
    A recent poll suggests that 6 out of 7 dwarfs are not happy

    Comment


    • #3
      Would site level GPOs, or GPPs targeted on an AD site, be an option?
      Tom Jones
      MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
      PhD, MSc, FIAP, MIITT
      IT Trainer / Consultant
      Ossian Ltd
      Scotland

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

      Comment


      • #4
        If you place each server in a different Site (and create and configure appropriate subnet objects for each site), what you describe will happen automatically.

        When several replicas exist for a DFS Folder, clients will by default be directed to the replica in their own site. Of course, if you have a Site without a server hosting a DFS replica, the client will be directed to another server chosen basically at random.

        I guess you could control the drive mappings via GPO using item-level targeting, but then you would have to map directly to the shared folder on a server rather than the folder in the DFS namespace. Item-level targeting is available for every GPO stting under "Preferences" and it's an extremely powerful and flexible mechanism. You can create fairly complex conditions based on Site, OU, IP address, group membership and lots of other criteria.

        But in this particular case it does sound like DFS and properly configured Site objects would be the better solution.

        Comment


        • #5
          Ser Olmy is pretty much on spot. Just a few notes:

          - When setting up your AD Sites, you place domain controllers in sites only, not all servers. All other domain joined computers will determine their site by the subnet they're on. (which is why it's critical to define your subnets in ADSS)
          - Clients don't connect to DFS replicas, they connect to DFS namespaces. DFSN and DFSR are separate but related. Map your drives to the appropriate DFSN and, like Ser Olmy said, they should connect to the closest server provided your AD Sites are setup properly.
          - DFS referrals are not random but based on the AD site topology. So again, make sure you AD Sites are setup correctly.
          Regards,
          Jeremy

          Network Consultant/Engineer
          Baltimore - Washington area and beyond
          www.gma-cpa.com

          Comment


          • #6
            Thanks for all the suggestions. Tried a If %logonserver% = bat file and had mixed results. Never had to mess with AD Sites before so will have to look into that before I start messing around with it. Behind schedule on getting the office up and running so the last thing I need is to have communication down between the two servers because I'm playing around.

            Thanks Again

            Comment


            • #7
              Check out this post on Spiceworks' forum
              A recent poll suggests that 6 out of 7 dwarfs are not happy

              Comment


              • #8
                Originally posted by xjstever81 View Post
                Tried a If %logonserver% = bat file and had mixed results.
                This will not be effective for several reasons, one being that you don't have AD sites configured. Logons will go equally to any DC no matter what location they're in since sites are not setup.

                Another reason is that if you do have sites setup and a user travels from one set to another, it will have some stickiness to the other site's server. It needs to see that it's in the new site (done after logon) and any subsequent logons will be handled by a closer server.

                If you really want to do it by script, it should check what subnet it's on and map accordingly. However, setting up sites is not difficult and DFS would be simpler and more robust, IMO.
                Regards,
                Jeremy

                Network Consultant/Engineer
                Baltimore - Washington area and beyond
                www.gma-cpa.com

                Comment

                Working...
                X