Home
Join

6 Replies

  • Not sure if this helps or not, but there is a printer port admin VB script that comes with WIndows.

    C:\Windows\System32\Printing_Admin_Scripts\en-US\prnport.vbs

    At the very least, perhaps you can take a look at the script and see how it does what it does and then find the "PowerShell way" to do it.

    Pepper graySpice (1) flagReport
    1 found this helpful thumb_up thumb_down
  • It looks like you just need to do a little cleanup on your server then you can use the script as is. When you see a portname is an underscore, that means there are at least two entries for the same IP. That should not be necessary.  On your print server, go into printmanagement.msc then under ports locate any/all duplicates and clean them up. If you have any printers using one with an underscore, go to that printer first and change the port to the correct portname without the underscore before removing the duplicate.

    Pepper graySpice (1) flagReport
    1 found this helpful thumb_up thumb_down
  • Hi, the screenshot is of thw printers port not the printer.
    I don't think you can rename it but you can create new ones correctly with:
    Best
    Sean

    Powershell
    Add-printerport -name "this is the comment" -printerhostadress "ip here" 
    

    Was this post helpful? thumb_up thumb_down
  • You can use Get-PrinterPort to get the IP/Hostname information:

    Powershell
    $PrintServer = "YOUR-PRINT-SERVER.DOMAIN.Local"
    $Printers = get-printer -ComputerName $PrintServer
     
    foreach ($Printer in $Printers){
        $Address = (Get-PrinterPort $Printer.PortName).PrinterHostAddress
        Set-Printer -Name $Printer.name -ComputerName $PrintServer -Comment $Address
    }
    

    d

    Pepper graySpice (4) flagReport
    2 found this helpful thumb_up thumb_down
  • Check this link for a powershell gui for creating printers, maybe you can take some ideas from it:
    https://community.spiceworks.com/scripts/show/4207-powershell-gui-enhanced-printer-infrastructure-creator-or-e-p-i-c

    Was this post helpful? thumb_up thumb_down
  • You can use Get-CimInstance instead

    Powershell
    Get-CimInstance -Class Win32_Printer -ComputerName YOURPRINTSERVER
    

    The property you're looking for is PortName

    If you want to audit all of your printers, here's a script I wrote to do that.
    https://community.spiceworks.com/scripts/show/5058-get-printer-configuration-and-status-information-...

    Unfortunately, it doesn't record the PortName in the output, but would be easy to add:

    Something like this should work

    Powershell
    $Port = [PSCustomObject]@{
        Name            =   $Printer.PortName
        HostAddress     =   $_.HostAddress
        IPAddress       =   if ($_.HostAddress -as [IPAddress] -as [Boolean] -eq $true) {
                                $_.HostAddress
                            } else {
                                Resolve-DnsName -Name $_.HostAddress.Replace(' ', '') -Type A -QuickTimeout -ErrorAction SilentlyContinue | Select-Object -ExpandProperty IP4Address
                            }
        SNMPEnabled     =   $_.SNMPEnabled
        SNMPCommunity   =   $_.SNMPCommunity
    }
    
    Was this post helpful? thumb_up thumb_down

Read these next...

  • Today's amusing website request

    Today's amusing website request

    Water Cooler

    From a side group that I handle:We need to update the address information on the website.  (It's on a few different pages).Can you export the website to Microsoft Word so that we can just search and replace?Funniest request I've gotten in a while.On a sid...

  • Standalone private mail server

    Standalone private mail server

    Security

    Hi team, all this post is about personal use,Since few months, or even years, having all my mails on google servers is bothering me. So I am seriously thinking about creating a standalone mail server here in my home. The aim is not either to create huge s...

  • Snap! -- Titan, Sentient AI, Chatbot Tests, Rat Czar, Wireless Electricity

    Snap! -- Titan, Sentient AI, Chatbot Tests, Rat Czar, Wireless Electricity

    Spiceworks Originals

    Your daily dose of tech news, in brief. Welcome to the Snap! Flashback: Back on December 2, 1954, The US Navy dedicates its Naval Ordnance Research Calculator (NORC) (Read more HERE.) Bonus Flashback: Back on December 2, 1995, NASA launch...

  • They had ONE job!

    They had ONE job!

    Security

    Was trying to be a nice IT person.Transferred user computer profile from one desktop to another. All went well, no real issues, just a couple of apps the user needed to install, like Citrix Workspace. So I left local admin rights for the users account to ...

  • Spark! Pro series – 2nd December 2022

    Spark! Pro series – 2nd December 2022

    Spiceworks Originals

    I don’t know about you, but I am feeling the Christmas Spirit.  The tree is up, the packages are wrapped, the house and yard are decorated.  And the Eggnog is spiked!  Happy Friday Y’all! Just a reminder, if ...