- Joined
- Jul 27, 2006
- Messages
- 9,484
Greetings,
I have this script that I have been using to mass create printers via PowerShell and a CSV file:
From the first column to the last (left to right):
The above is tested and works. Script execution takes longer when it processes laser printers, but processes text and label printer creations pretty fast in comparison; noting this from experience and observation.
Question: how can I use PowerShell to set the orientation, width, length, and margins of printer also?
Right now I am having to manually go edit nearly one hundred (100) thermal label printers that I created with this script to set width and length to 3x5 (inches) with 0 margins (all around) and Landscape orientation instead of Portrait. If this could be part of the script, that would be even better.
I have this script that I have been using to mass create printers via PowerShell and a CSV file:
Code:
function CreatePrinterPort {
$server = $args[0]
$port = ([WMICLASS]“\\.\ROOT\cimv2:Win32_TCPIPPrinterPort”).createInstance()
$port.Name= $args[1]
$port.SNMPEnabled=$false
$port.Protocol=1
$port.HostAddress= $args[2]
$port.Put()
}
function CreatePrinter {
$server = $args[0]
$print = ([WMICLASS]“\\.\ROOT\cimv2:Win32_Printer”).createInstance()
$print.drivername = $args[1]
$print.PortName = $args[2]
$print.Shared = $true
$print.Published = $false
$print.Sharename = $args[3]
$print.Location = $args[4]
$print.Comment = $args[5]
$print.DeviceID = $args[6]
$print.Put()
}
$printers = Import-Csv “printers.csv”
foreach ($printer in $printers) {
CreatePrinterPort $printer.Printserver $printer.Portname $printer.IPAddress
CreatePrinter $printer.Printserver $printer.Driver $printer.Portname $printer.Sharename $printer.Location $printer.Comment $printer.Printername
}
From the first column to the last (left to right):
- Printserver (ex. DFW-PRNTSRVR1)
- Driver (ex. ZDesigner LP 2844)
- Portname (ex. 192.168.1.40)
- IPAddress (same value as Portname)
- Sharename (ex. CORP-LB.43)
- Location (ex. John's office)
- Comment (can put any text string here)
- Printername (same value as Sharename)
The above is tested and works. Script execution takes longer when it processes laser printers, but processes text and label printer creations pretty fast in comparison; noting this from experience and observation.
Question: how can I use PowerShell to set the orientation, width, length, and margins of printer also?
Right now I am having to manually go edit nearly one hundred (100) thermal label printers that I created with this script to set width and length to 3x5 (inches) with 0 margins (all around) and Landscape orientation instead of Portrait. If this could be part of the script, that would be even better.
Last edited: