Hi all,<\/p>\n
trying to wrap my head around how to throttle the adding of all the printers via the below PS script. There’s approx. 200 printers on the print server and I’m installing all of them on a master VDI image so GP won’t hose the user’s session the first time they connect if I did it that way instead. Every time I run the script it does work mostly but it never completes due to the sheer number of printers it’s trying to install at once. The whole desktop gets covered in Adding printer dialogs and then ultimately freezes up requiring a vm reset thus only partially installing what I need. VM is Windows 10 Ent., domain joined, domain admin account.<\/p>\n
$printers = Get-Printer -Computername ps1
\n$server = \"\\ps1\"
\nForEach ($printer in $printers) {
\n$printermap = $server + $printer.name
\nInvoke-Expression ‘rundll32 printui.dll PrintUIEntry /ga /in /q /n $($printermap)’
\n}<\/p>\n
$printers = Get-Printer -Computername ps1\n$server = \"\\\\ps1\\\"\nForEach ($printer in $printers) {\n $printermap = $server + $printer.name\n Invoke-Expression 'rundll32 printui.dll PrintUIEntry /ga /in /q /n $($printermap)'\n}\n<\/code><\/pre>\nIf there’s a better way I’m open to it.<\/p>\n
Please and thank you.<\/p>","upvoteCount":4,"answerCount":7,"datePublished":"2021-04-28T18:15:11.000Z","author":{"@type":"Person","name":"ryno252","url":"https://community.spiceworks.com/u/ryno252"},"acceptedAnswer":{"@type":"Answer","text":"
a ‘dumb’ solution would be just to add sleep?
\ne.g.<\/p>\n
$printers = Get-Printer -Computername ps1\n$server = \"\\\\ps1\\\"\nForEach ($printer in $printers) {\n $printermap = $server + $printer.name\n Invoke-Expression 'rundll32 printui.dll PrintUIEntry /ga /in /q /n $($printermap)'\n start-sleep -seconds 2 #wait 2 seconds\n}\n<\/code><\/pre>","upvoteCount":2,"datePublished":"2021-04-28T18:50:18.000Z","url":"https://community.spiceworks.com/t/install-all-network-printers-powershell-script-help/798312/3","author":{"@type":"Person","name":"Neally","url":"https://community.spiceworks.com/u/Neally"}},"suggestedAnswer":[{"@type":"Answer","text":"Hi all,<\/p>\n
trying to wrap my head around how to throttle the adding of all the printers via the below PS script. There’s approx. 200 printers on the print server and I’m installing all of them on a master VDI image so GP won’t hose the user’s session the first time they connect if I did it that way instead. Every time I run the script it does work mostly but it never completes due to the sheer number of printers it’s trying to install at once. The whole desktop gets covered in Adding printer dialogs and then ultimately freezes up requiring a vm reset thus only partially installing what I need. VM is Windows 10 Ent., domain joined, domain admin account.<\/p>\n
$printers = Get-Printer -Computername ps1
\n$server = \"\\ps1\"
\nForEach ($printer in $printers) {
\n$printermap = $server + $printer.name
\nInvoke-Expression ‘rundll32 printui.dll PrintUIEntry /ga /in /q /n $($printermap)’
\n}<\/p>\n
$printers = Get-Printer -Computername ps1\n$server = \"\\\\ps1\\\"\nForEach ($printer in $printers) {\n $printermap = $server + $printer.name\n Invoke-Expression 'rundll32 printui.dll PrintUIEntry /ga /in /q /n $($printermap)'\n}\n<\/code><\/pre>\nIf there’s a better way I’m open to it.<\/p>\n
Please and thank you.<\/p>","upvoteCount":4,"datePublished":"2021-04-28T18:15:11.000Z","url":"https://community.spiceworks.com/t/install-all-network-printers-powershell-script-help/798312/1","author":{"@type":"Person","name":"ryno252","url":"https://community.spiceworks.com/u/ryno252"}},{"@type":"Answer","text":"
If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>\n