augustkrys
asked on
Add multiple TCP/IP Printer ports at once using Powershell
I am very new to powershell to start. I need to create multiple printer ports on a single server. I can use
Add -PrinterPort to do this one at a time like:
Add-PrinterPort -PrinterHostAddress 192.168.1.55 -SNMP 1 -SNMPCommunity public -Name tester
How can I use all the same parameters but change the IP ?
Add -PrinterPort to do this one at a time like:
Add-PrinterPort -PrinterHostAddress 192.168.1.55 -SNMP 1 -SNMPCommunity public -Name tester
How can I use all the same parameters but change the IP ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad it helped and it looks like you've done well with the 2008 script too :)
ASKER
#Import the CSV list
$IPList=get-content C:\file.csv
#For testing Lists each item in the above file
#$IPList | FOREACH-OBJECT {$_}
FOREACH ($ip in $IPList) {
print $ip
$port = [wmiclass]"Win32_TcpIpPrin
$port.psbase.scope.options
$newPort = $port.CreateInstance()
$newport.name = "$ip"
$newport.Protocol = 1
$newport.HostAddress = $ip
$newport.PortNumber = "9100"
$newport.SnmpEnabled = $false
$newport.Put()
}