I have been working on a script to remove a locally added network IP Printer - that was originally added using the print wizard with plug and play drivers not hosted on a print server - from a few machines in my area at work. The problem that I have ran into is that whenever I query the correct printer using the following command the “delete” method removes the record from WMI, but the printer info remains in the “Devices and Printers” GUI even though you cannot print to it.
(Get-WmiObject -class win32_printer | where-object {$_.Name -eq "PRINTER (HP LaserJet 500 color M551)"} ).delete()
I initially thought that I was possibly forgetting to remove the win32_tcpipprinterport, but it does not use a tcpip port. I also thought that it might even have an authentication issue as the UAC is prompted when the printer is removed manually, but I could not find anything on this by searching the web. I would appreciate any insight on what may be going on. I also included a print out below of the cmdlet above excluding the delete method.
PSComputerName : TestComputer Status : Unknown Name : PRINTER (HP LaserJet 500 color M551) __GENUS : 2 __CLASS : Win32_Printer __SUPERCLASS : CIM_Printer __DYNASTY : CIM_ManagedSystemElement __RELPATH : Win32_Printer.DeviceID="PRINTER (HP LaserJet 500 color M551)" __PROPERTY_COUNT : 86 __DERIVATION : {CIM_Printer, CIM_LogicalDevice, CIM_LogicalElement, CIM_ManagedSystemElement} __SERVER : TestComputer __NAMESPACE : root\cimv2 __PATH : \\TestComputer\root\cimv2:Win32_Printer.DeviceID="PRINTER (HP LaserJet 500 color M551)" Attributes : 576 Availability : AvailableJobSheets : AveragePagesPerMinute : 0 Capabilities : {4, 2, 3, 5} CapabilityDescriptions : {Copies, Color, Duplex, Collate} Caption : PRINTER (HP LaserJet 500 color M551) CharSetsSupported : Comment : ConfigManagerErrorCode : ConfigManagerUserConfig : CreationClassName : Win32_Printer CurrentCapabilities : CurrentCharSet : CurrentLanguage : CurrentMimeType : CurrentNaturalLanguage : CurrentPaperType : Default : False DefaultCapabilities : DefaultCopies : DefaultLanguage : DefaultMimeType : DefaultNumberUp : DefaultPaperType : DefaultPriority : 0 Description : DetectedErrorState : 0 DeviceID : PRINTER (HP LaserJet 500 color M551) Direct : False DoCompleteFirst : True DriverName : HP LaserJet 500 color M551 PCL6 EnableBIDI : False EnableDevQueryPrint : False ErrorCleared : ErrorDescription : ErrorInformation : ExtendedDetectedErrorState : 0 ExtendedPrinterStatus : 2 Hidden : False HorizontalResolution : 600 InstallDate : JobCountSinceLastReset : 0 KeepPrintedJobs : False LanguagesSupported : {50} LastErrorCode : Local : True Location : MarkingTechnology : MaxCopies : MaxNumberUp : MaxSizeSupported : MimeTypesSupported : NaturalLanguagesSupported : Network : False PaperSizesSupported : {7, 8, 1, 1...} PaperTypesAvailable : Parameters : PNPDeviceID : PortName : WSD-af3c56c0-8fef-4253-9512-fd17a59f565f.0067 PowerManagementCapabilities : PowerManagementSupported : PrinterPaperNames : {Letter, Legal, Statement, Executive...} PrinterState : 0 PrinterStatus : 3 PrintJobDataType : RAW PrintProcessor : hpcpp145 Priority : 1 Published : False Queued : False RawOnly : False SeparatorFile : ServerName : Shared : False ShareName : SpoolEnabled : True StartTime : StatusInfo : SystemCreationClassName : Win32_ComputerSystem SystemName : TestComputer TimeOfLastReset : UntilTime : VerticalResolution : 600 WorkOffline : False Scope : System.Management.ManagementScope Path : \\TestComputer\root\cimv2:Win32_Printer.DeviceID="PRINTER (HP LaserJet 500 color M551)" Options : System.Management.ObjectGetOptions ClassPath : \\TestComputer\root\cimv2:Win32_Printer Properties : {Attributes, Availability, AvailableJobSheets, AveragePagesPerMinute...} SystemProperties : {__GENUS, __CLASS, __SUPERCLASS, __DYNASTY...} Qualifiers : {dynamic} Site : Container :