Creat Print Server Ports and Names

Welcome Forums General PowerShell Q&A Creat Print Server Ports and Names

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
2 weeks, 3 days ago.

  • Author
    Posts
  • #180881

    Participant
    Topics: 1
    Replies: 1
    Points: 20
    Rank: Member

    Good Day,

    I am very noobish to PowerShell, but I'm trying my best to learn.

    I have a printer server named PAPER01. I have a list of I.P. addresses. I would like to create a TCP/IP port for each I.P. address and name the port. I have a list of names that corrospond to the I.P. address.

    What would a script look like that creates a port from a CSV list of I.P.s and name the ports to the desired name?

    eg.,

     

    IP                    Name

    10.0.0.0         PortName1

     

    Kindest Regards,

     

    Matt

  • #180950

    Participant
    Topics: 6
    Replies: 97
    Points: 239
    Helping Hand
    Rank: Participant

    This may be a pretty good starting point: https://lazyadmin.nl/powershell/install-a-printerport-and-printer-with-powershell/

    It sounds like it will just be a loop through your CSV and for each record you'll build and execute an Add-PrinterPort cmdlet.

  • #180998

    Participant
    Topics: 1
    Replies: 1
    Points: 20
    Rank: Member

    Here is what I ended up doing that worked for me:

     

    #Create a variable for the IPs from a .txt file

    $IPsA = get-content c:\temp\ip.txt

    #Once the variable has been made create an argument to create a port from each IP and name it the IP.

    ForEach ($IP in $IPsA) {add-printerport -printerhostname $IP -name $IP -computername }

     

You must be logged in to reply to this topic.