Home > Script Error > Script Error Querying The Default Printer

Script Error Querying The Default Printer

Let me know if it works out for you. <# .SYNOPSIS Logon Script to migrate printer mappings from A23|U32 to A25 for Windows 7 users .DESCRIPTION Logon Script to migrate printer The only improvement would be if it kept the default printer. IT works great but what about if user has mapped printers from 5 different print servers. Let me know your thoughts, Michael July 3, 2014 at 7:14 am #16764 Rob SimmersParticipant The issue with op_Addition was most likely caused by line 10 because I didn't have += have a peek at this web-site

Reply Andy says: 12/04/2014 at 8:10 am Nice Script!! Would it be a good idea to run 2 scripts each using 1 print server? Add one in the admin panel. If just one, does that box have a default printer defined and avaliable? 2 Posts 2 Karma mst posted this 05 August 2013 Yes, it's happening with the current Bonuses

What line did you change the server name? The code I had did remap them, but did not set the default printer. Link Cancel replyLeave a Comment Name Email Website Comment Current [emailprotected] * Leave this field empty Next post: Manage print jobs from command linePrevious post: Rename local user account E-mail Newsletter The script works great.

Reply Link Jeffwmic printer get name, default only captures and returns the local printers, not networked printers. So, if you have 300 people in your environment and Monday @ 8:00 there are 100 people logging in, that file is going to open by someone and the script is The command for this would be.wmic printer where name='Eng_Printer_1stFloor' call setdefaultprinterThis command also works on Server 2008. That has been fixed.

All credit goes to Boe Prox at the above link for this script. Change the last line to this if the default printer is not on the same print server that you are migrating from: (New-Object -ComObject WScript.Network).SetDefaultPrinter("\\"+$newPrintServer+"\"+$default.ShareName)\ The format has to be \\printserver\sharename Param ( $newPrintServer = "svrprint1", $PrinterLog = "\\file\share\{0}_PrintMigration.csv" -f $Env:COMPUTERNAME ) $log = @() if (Test-Path $PrinterLog) { #pull in the current log to 'Append' new logging $log += Import-CSV $printerLog https://social.technet.microsoft.com/Forums/windowsserver/en-US/777091d8-5851-4cd8-ac38-5d3dc2408992/trying-to-set-default-printer-during-migration?forum=winserverpowershell I did not actually update the code on line 21 or 22, which is your replace and .AddPrinterConnection.

Though I have not verified it, it should work for other Windows editions also(XP, Vista, Server 2003).Related Posts:Printer management in XP, Server 2003 from Windows command line. The only error I get is the following: Exception calling "SetDefaultPrinter" with "1" argument(s): "There is no printer called "Lex-Finance"." At \\server1\SYSVOL\domain.org\scripts\remap-printers-printserver.ps1:70 char:67 + (New-Object -ComObject WScript.Network).SetDefaultPrinter <<<< ($default.S hareName) + Add one in the admin panel. All clients are Win7 with PowerShell 2.0.

So, would need to get details on logic, but yes it could be a single script (and should be). This script is run from the logon script and run on all users. You didn't mention what kind of numbers you have in your environment, but you are using a SINGLE log file for every computer running a login script. Anyone who is a guru in this?

You can get the name field using wmic printer get name. Check This Out Thx, M Author Posts You must be logged in to reply to this topic. Powershell Logon Script to update printer mappings and keep the default printer. To answer your question directly, the .SetDefaultPrinter() method is looking for the Name of the printer, not the ShareName.

But it doesn't work to set the default printer. There is no reason one script cannot handle both print servers. But in the csv it says it added the printers: Successfully added \\hqfp00\Lex-Finance [DEFAULT] with return value 0 July 4, 2014 at 3:58 am #16778 Michael BurutzisParticipant I had changed the Source If you are OK with the more general monitoring available in the default MP’s they will work just fine.

Skip to toolbar About WordPress WordPress.org Documentation Support Forums Feedback Log in Register Search Null Payload Daily musings of an IT Professional. Does this happen on every box, or just one? Printers became a huge hassle.

That has been fixed.

You need to capture #if the delete was successful during your testing if the #event your code needs updated. I am trying to understand bit by bit how powershell works. Can we run this script against 5 different servers. If a user had \\oldserver1\printer1 and \\oldserver2\printer1 mapped, you would have to handle deleting both and only mapping 1 server.

Something that I didn't think of adding was a way to set the default printer in the logon script. Did you update the "svrPrint" to the actual print server name and pass a parameter for $newPrintServer (or update the default) to reflect actual servers in your environment. You need to capture #if the delete was successful during your testing if the #event your code needs updated. http://internetmairie.com/script-error/script-error-fix.html I added some columns to make it easier to filter your results.

Link adminThe command lists network printers for me too. Required fields are marked *Comment Name * Email * Website Archives February 2016(1) October 2014(3) August 2014(1) July 2014(1) June 2014(1) March 2014(1) January 2014(1) December 2013(1) November 2013(1) September 2013(1) You could do Export-CSV and send to Desktop Support or run a script to re-mediate the issue you're having. Thanks a lot!

Search for: 06/18/2014 by Chris Found a powershell script online here: learn-powershell.net/2012/11/15/use-powershell-logon-script-to-update-printer-mappings/ that uses WMI to query locally mapped printers, delete them, and reconnect them from a different print server.