[
    {
        "role": "user",
        "content": "Give%20powershell%20command%20to%20add%20a%20new%20printer%2C%20an%20HP%20LaserJet%205n%20on%20tcp%2Fip%20192.168.0.20%20using%20HP%20Universal%20PCL5%20driver"
    },
    {
        "role": "assistant",
        "content": "Here\u2019s a set of PowerShell commands to add an HP LaserJet 5n printer on TCP/IP address **192.168.0.20** using the **HP Universal PCL5** driver. You\u2019ll want to run this in a PowerShell session **as Administrator**.\n\n---\n\n```powershell\n# 1. Import the PrintManagement module (if not already imported)\nImport-Module PrintManagement\n\n# 2. (Optional) Add the HP Universal PCL5 driver to the driver store if it's not already present.\n#    Adjust the path to your .inf file accordingly.\n$driverName = \"HP Universal Printing PCL5\"\n$infPath = \"C:\\Drivers\\HP\\UPD\\HPUniversalPDL_PCL5\\hpcu250u.inf\"  # example path\nAdd-PrinterDriver -Name $driverName -InfPath $infPath\n\n# 3. Create a TCP/IP printer port for IP 192.168.0.20\n$portName = \"IP_192.168.0.20\"\nAdd-PrinterPort -Name $portName -PrinterHostAddress \"192.168.0.20\"\n\n# 4. Add the printer, linking it to the driver and port\nAdd-Printer -Name \"HP LaserJet 5n\" -DriverName $driverName -PortName $portName\n```\n\n---\n\n### Explanation & Tips\n\n- **PrintManagement module**: This provides `Add-PrinterPort`, `Add-PrinterDriver`, `Add-Printer`, etc. ([alyaconsulting.ch](https://alyaconsulting.ch/Solutions/PrintManagement/Add-PrinterPort?utm_source=openai))  \n- **Add-PrinterDriver**: Installs the printer driver. If the driver\u2019s already installed, this cmdlet will usually succeed indicating it's already present. Make sure the driver .inf path is correct. ([reddit.com](https://www.reddit.com/r/PowerShell/comments/17bp6kt?utm_source=openai))  \n- **Add-PrinterPort**: Creates the TCP/IP port using `-PrinterHostAddress`. The port name can be anything, but it\u2019s often helpful to name it after the IP for clarity. ([pdq.com](https://www.pdq.com/powershell/add-printerport/?utm_source=openai))  \n- **Add-Printer**: The final step, associates the port and driver with a new printer name. ([lazyadmin.nl](https://lazyadmin.nl/powershell/install-a-printerport-and-printer-with-powershell/?utm_source=openai))  \n\n---\n\nIf you like, I can include optional parameters\u2014like sharing the printer, publishing it in Active Directory, or specifying SNMP community settings\u2014just let me know."
    }
]