This sample can help you resolve the issue “The new printer status is Offline after you delete a print queue and then restart a Windows-based computer” described in KB2027593. It demonstrates how to list printers, print queues and how to delete evil registry key for print queue by using PowerShell script. This script completes the tasks by using registry and WMI Win32_Printer class.
Consider the following scenario:
- You delete a print queue while it is in an Offline status.
- You add a new print queue that has the same name as the old print queue.
- You restart the computer.
In this scenario, the status of the new print queue is displayed as Offline. To solve this issue, you can use this script to get and remove evil registry key which cause the problem after you delete a print queue but before you add a new print queue of the same name.
You can find more All-In-One Script Framework script samples at https://aka.ms/onescriptingallery