We help IT Professionals succeed at work.
Get Started

Calling powershell script server 2008r2 -- Default Printer

174 Views
Last Modified: 2015-07-09
I have a 2012r2 print server with about 30 printers that I assign to specific OUs via "launch with Group Policy" from the printer management snapin.  I then assign the specific printers to their corresponding OUs.  That works fine.  However, from what I've read you can't create a default printer if you assign printers that way.  So, I created a powershell script, tested it locally (worked) and then went to the specific OU on a 2008r2 server, computer config --> policies --> windows settings --> scripts and added it to the powershell scripts tab and told windows to "run windows powershell scripts first"  

The workstations in that particular OU are receiving the GPO with the default printer powershell script however, they aren't setting the default printer.  Yet if I run the script locally from the desktop, it works without issue and sets the default printer.  All workstations are Windows 7 enterprise.  I've attached the power shell script code below (wouldn't allow upload) as well (with server and printer names set to "server" and "printer" for security).  

Set-ExecutionPolicy Bypass
$TargetPrinter = "\\server\printer"
$ErrorActionPreference = “SilentlyContinue”

$LocalPrinter = GWMI -class Win32_Printer |

Where {$_.Name -eq $TargetPrinter}

$LocalPrinter.SetDefaultPrinter()


Again, the above script works without issue locally, just not via the GPO even though running rsop.msc confirms it ran.
Comment
Watch Question
Senior Citrix Engineer
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE