2

I am trying to map a default printer based on the location found in AD Sites and Services. I can grab the location of the computer using [System.DirectoryServices.ActiveDirectory.ActiveDirectorySite]::GetComputerSite().Name

Once I have grabbed the location, I would like it to map 2 printers based on the location. Each of our 10 sites has 2 default printers that I would like "Domain Users" to have. Then any security group related ones are mapped via another script I already have.

I already have a script in place using VB to do this - but as I am currently learning PS, I would like some pointers on this.

Thanks in advance

GregL
  • 9,030
  • 2
  • 24
  • 35
  • Why not create ten GPOs containing the 2 printers for each site, then link the GPOs to respective site? – ErikE Aug 18 '15 at 10:38
  • But what if a user goes from one branch office to another, he/she will not get printers list updated and will use the printers in his/her native location. – Volodymyr Molodets Aug 18 '15 at 11:29

2 Answers2

1

I love scripting, but this is probably one thing that you do not need to script. I think the most official and standard way to do this is by sharing the printers from a "print server," either one centralized one or a print server in each site. It is common practice to add this print server role onto another server that's already performing some other function, such as a file server. File and print services often go well together. Use the Print Management console to install, share, deploy and publish the printers. If you link a GPO to each site, and then deploy the printers using those site-linked GPOs, the users will get an updated list of printers as they move around between sites.

Printers

Ryan Ries
  • 55,011
  • 9
  • 138
  • 197
  • Can't upvote this enough; I love PowerShell, but this is a solved problem, and Ryan is demonstrating the correct way to address this. It just works. – jbsmith Aug 18 '15 at 22:35
0

Setup All the printers for the users, and switch the deafult printer based on the site, for example:

$CurrentSite = [System.DirectoryServices.ActiveDirectory.ActiveDirectorySite]::GetComputerSite().Name

    Switch ($CurrentSite)
    {

    "SiteA" {
    $Printer = gwmi win32_printer -filter "Name='SiteA-PrinterName'"
    $Printer.SetDefaultPrinter()
    }

    "SiteB" {
    $Printer = gwmi win32_printer -filter "Name='SiteB-PrinterName'"
    $Printer.SetDefaultPrinter()
    }

    "SiteC" {
    $Printer = gwmi win32_printer -filter "Name='SiteC-PrinterName'"
    $Printer.SetDefaultPrinter()
    }

    "SiteD" {
    $Printer = gwmi win32_printer -filter "Name='SiteD-PrinterName'"
    $Printer.SetDefaultPrinter()
    }

}
Avshalom
  • 161
  • 7
  • Hi this is what i was looking for, but i want it to only map the printers for the site and not have all the printers installed - O/S is 8.1 – Chiller_chills Aug 20 '15 at 12:55