I have a script that was created for Windows 2008 R2 which sets the default printer of a host.
This script is used for large scale environments and uses the Get-WMIObject method to retrieve a list of printers.
Due to some issues with a print driver, we need to utilize the new get-printer method but I CANNOT locate how to set a default printer with data pulled using get printer.
The new code fails due to the way get-printer returns results. I have tried limiting to $defaultprinter.name and other variations with no luck
Is anyone aware of a different method of setting the default printer with output from get-printer?
I have exampled set-printer, set-printerproperty with no luck
Default printers are a per-user setting, so this probably isn’t going to work quite the way you expect it to.
The new CIM classes that Get-Printer returns don’t have a method to set the default printer. You can either fall back to WMI, or use the old WScript.Network COM object. For example:
Thank you for the reply. Yes understood its only for my self. Basically what I am doing is running this on thousands of workstations to grab a random printer from printers that are already mapped and make a random one the default printer.
This is for a very specific purpose. Unfortunately there is no method using the new classes. The WMI way causes an undesirable result on our print server at this large of a scale. I have proven that the get-printer method has much less of an impact.