• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

PowerShell: set width, length, and margins for printer when creating printer

Cerulean

[H]F Junkie
2FA
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:
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:
Back
Top