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.
Here is an example
OLD CODE: (WORKS)
$printers = get-wmiobject win32_printer $defaultprinter = $printers | get-random $defaultprinter.setDefaultPrinter()
NEW CODE (DOES NOT WORK)
$printers = get-printer $defaultprinter = $printers | get-random $defaultprinter.setDefaultPrinter()
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