Link to home
Start Free TrialLog in
Avatar of namerg
namergFlag for United States of America

asked on

How delete printer names and tcp/ip ports ?

I am stuck in removing certain printers with tcp/ip ports using Remove-PrinterPort. I get the following error

Remove-PrinterPort -Name "PA-HP Plotter"
Remove-PrinterPort: No MSFT_PrinterPort objects found with property 'Name' equal to 'PA-HP Plotter'.  Verify the value of the property and retry.

Open in new window

User generated image

My first goal is to verify if the following printer names exist "HP Printer PS", 

"Xerox B215 Multifunction Printer PS" and "PA-HP Plotter" and delete them if they do exist with the respective ports.


Thansk for your help

Avatar of Greg Besso
Greg Besso
Flag of United States of America image

I'm not that familiar with this specific one, but have you tried first querying with Get-PrinterPort and then If (something something) { then do the stuff}? Just worth checking.



Avatar of namerg

ASKER

Yep, I have tried Get-PrinterPort and queries fine with the expected results..

Ah understood. Perhaps check the -Name value you are using. Is it exact? One way I can imagine might work.


$getports = Get-PrinterPort


$thisport = $getPorts[0] # assuming its the first one.


Then Remove-PrinterPort -Name $thisPort.Name


Just thinking out loud, possibly the value stored is different than what is being entered?

ASKER CERTIFIED SOLUTION
Avatar of Seth Simmons
Seth Simmons
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of namerg

ASKER

Hmm, will try both suggestions later
Avatar of namerg

ASKER

Well, it does remove them...but I was expecting to have tcp/ip port removed as well. The tcp/ip port stays but unchecked.

User generated image
Avatar of namerg

ASKER

Well, I guess it does not impact what I am trying to accomplish. I did add the printer via powershell using the same tcp/ip port and was added fine. Thanks for your input anyway