Jump to content
  • entries
    2
  • comments
    0
  • views
    492

Clever little printer trick. (a note to self)


2 steps to have printers just print to the IP of the printer:

run on startup: pnputil /a 'driver.inf'

Preferably a v4 printer

 

then on login:

$CurrentUser = [system.Security.Principal.WindowsIdentity]::GetCurrent()
$WindowsPrincipal = New-Object System.Security.Principal.WindowsPrincipal($CurrentUser)

Add-printerport -Name "TCPPort:printerdns/ip" -PrinterHostAddress "printerdns/ip" -ErrorAction SilentlyContinue

Add-PrinterDriver -name "Kyocera TASKalfa 4053ci v4 KX (XPS)" -ErrorAction SilentlyContinue
Add-PrinterDriver -name "Kyocera TASKalfa 4053ci KX" -ErrorAction SilentlyContinue
Add-PrinterDriver -name "Kyocera TASKalfa 4052ci KX" -ErrorAction SilentlyContinue

if ([system.DirectoryServices.ActiveDirectory.ActiveDirectorySite]::GetComputerSite().Name -eq "site1") {
 Add-Printer -Name "Name to appear to users" -PortName "TCPPort:thatDNSorIPfromEarlier" -driver "Kyocera TASKalfa 4053ci v4 KX (XPS)" -ErrorAction SilentlyContinue
 set-printconfiguration -color $false -printername "Name to appear to users"  -ErrorAction SilentlyContinue
 $printer = Get-CimInstance -Class Win32_Printer -Filter "Name='Name to appear to users'"
 Invoke-CimMethod -InputObject $printer -MethodName SetDefaultPrinter
 if (-not $WindowsPrincipal.IsInRole("PupilsGroup")) {
   Add-Printer -Name "Office printer" -PortName "TCPPort:..."   -driver "Kyocera TASKalfa 4053ci v4 KX (XPS)" -ErrorAction SilentlyContinue
   Add-Printer -Name "Office printer v3" -PortName "TCPPort:...."   -driver "Kyocera TASKalfa 4052ci KX" -ErrorAction SilentlyContinue
   set-printconfiguration -color $false -printername "Office printer" -ErrorAction SilentlyContinue
   if ($WindowsPrincipal.IsInRole("OfficeGroup")) {
     $printer = Get-CimInstance -Class Win32_Printer -Filter "Name='Office printer'"
     Invoke-CimMethod -InputObject $printer -MethodName SetDefaultPrinter
   }
 }
}
if ([system.DirectoryServices.ActiveDirectory.ActiveDirectorySite]::GetComputerSite().Name -eq "site2") {
   ....
}

0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...