My organization has a very strange problem. We have created various scripts to do certain tasks that are printer related. Tasks including deleting print jobs that have errors, changing drivers on printers, creating new printers, deleting unused printer ports, etc. All of these scripts use Get-Printer in some way. We have 3 print servers and use these scripts on all 3. The Get-Printer command works on 2 of the 3 servers. It used to work on the 3rd and I am not sure at what point things went bonkers. Let’s call this broken server SERVER3.
On the server it doesn’t work on I can:
And I get the following output:
get-printer : A general error occurred that is not covered by a more specific error code.
At line:1 char:1
+ CategoryInfo : NotSpecified: (MSFT_Printer:ROOT/StandardCimv2/MSFT_Printer) [Get-Printer], CimException
+ FullyQualifiedErrorId : MI RESULT 1,Get-Printer
If I use Get-Printer from the problem server to view printers on another server it works fine. Get-Printer from a remote server to the problem server does not work.
This works from the problem server:
[pre]Get-Printer -ComputerName SERVER2[/pre]
This gets the same error from a remote machine to the problem server:
[pre]Get-Printer -ComputerName SERVER3[/pre]
I tried to remove and install RSAT-Print-Services to see if that repaired Get-Printer:
Get-Printer still returns the same error message after this process. So I decide to see if I can do the WMI query from the problem server using the below:
Get-WmiObject MSFT_Printer -Namespace ROOT/StandardCimv2
The WMI command returns exactly 1 printer then immediately after the last property ‘PSComputerName’ it returns the following error:
Get-WmiObject : Generic failure
At line:1 char:1
+ Get-WmiObject MSFT_Printer -Namespace ROOT/StandardCimv2
+ CategoryInfo : InvalidOperation: ( [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
This is my first time posting here but I am at my wits end. If this isn’t the proper place to ask this question if someone could point me to a resource I could use it would be greatly appreciated. Most of our scripts I could edit them to use Get-CimInstance or Get-WmiObject instead but I am really trying to avoid that if possible. Just curious if anyone might have ran in to this before or have any ideas of what may be causing it. The funny thing is we built this server again from scratch because of this problem and it worked fine for a few months before once again coming to this point. I am wondering if it could possibly be an malformed or corrupt printer object that is causing the problem. I tried deleting the one that it returns and it just returned a different single printer before returning the error code.
Any help woudl be much appreciated. Also hello powershell.org!