Windows Server TechCenter > Windows Server Forums > Group Policy > Site only group policy script
Ask a questionAsk a question
 

AnswerSite only group policy script

  • Friday, November 06, 2009 3:24 PMmperone Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    i an trying to map printers w/ .vbs script to only one site, we have 3 sites in our domain. i would like to map printers to domain users laptop when they come to my site only.

    i have the scripts already, i need to know the bset way to apply the  gpo in sites and services, should it be a startup or a login? in computers or users policy?

    i dont want the scrpit to run when they go back to there sites.

    also we have acquired a new company and would need to map the printer to there laptops as well, but the laptop would not be part of our domain.

    we do have a two
    -way, transitive trust between the two.

Answers

All Replies

  • Friday, November 06, 2009 5:08 PMGuy Yardeni Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,
     Printer mappings are typically a per user setting and would therefore need to be applied to the user based logon script. You can make sure that the script is only run for users in a specific site by linked the GPO that runs the script to a site using the following process:

    1. Create the GPO and configure the script.
    2. In GPMC, expand the forest node
    3. Right click the sites node and select Show Sites
    4. Check the sites you need to link the GPO to and click OK.
    5. Right click the site and select 'Link an existing GPO'
    6. Select the GPO created earlier.

    A few things to think about:
    1. Depending on the commands used in your script, the printer mappings may be persistent and would therefore continue to appear on the client system even when they are on another site. To avoid this, make sure that the script doesn't map persistent printers.
    2. Or better yet, if your clients are XP SP2 or later and support GPO preferences, you can use the preference module to create printers in the following GPO location: User Configuration\Preferences\Control Panel Settings\Printers. By configuring the 'Remove this item when it is no longer applied' on the Common tab, you can make sure that the printers are not present when the system is connecting to another site.

    Guy
  • Friday, November 06, 2009 6:10 PMmperone Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    here is my script:

    Option Explicit
    Dim objNetwork, strLocal, strUNCPrinter1, strUNCPrinter2
    strUNCPrinter1 = "\\printserver\printer02"
    strUNCPrinter2 = "\\printerserver\printer10"
    Set objNetwork = CreateObject("WScript.Network")
    objNetwork.AddWindowsPrinterConnection strUNCPrinter1
    objNetwork.AddWindowsPrinterConnection strUNCPrinter2

    WScript.Quit

  • Friday, November 06, 2009 7:33 PMGuy Yardeni Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I believe that the AddWindowsPrinterConnection method will always add a persistent printer connection. 
    In that case you will most likely need to add code to the script to remove printers associated with other site or create a logoff script to remove the site's printers.

    What version is the client OS on these systems? GPO preferences would be a much easier solution.

    Guy
  • Friday, November 06, 2009 7:36 PMmperone Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    All machines are running Windows XP SP2
  • Friday, November 06, 2009 9:18 PMGuy Yardeni Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    In that case, I would consider deploying either the required CSE (http://www.microsoft.com/downloads/details.aspx?FamilyID=e60b5c8f-d7dc-4b27-a261-247ce3f6c4f8&displaylang=en) or SP3 and leveraging GPO preferences.
    In addition to addressing the Printer deployment problem, GPO preferences will allow you to control the systems in a manner above and beyond what GPOs can currently do.


    Guy