This repository has been archived on 2024-09-06. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
win_configscripts/Add-Printer.ps1
2021-01-31 22:36:14 +01:00

21 lines
728 B
PowerShell
Executable file

param (
[Parameter(Mandatory=$true)][string]$Inf,
[Parameter(Mandatory=$true)][string]$Ip,
[Parameter(Mandatory=$true)][string]$DriverName,
[Parameter(Mandatory=$false)][string]$Name="",
[Parameter(Mandatory=$false)][string]$PortPrefix = "salt_"
)
Import-Module -Name "$PSScriptRoot\lib\ManagePrinter.psd1" -Force
if ( -Not $Name ) {
Write-Verbose "Printer name was not set, using Driver name instead"
$Name = $DriverName
}
try {
Add-NetworkPrinter -Inf $Inf -Ip $Ip -Driver $DriverName -PrinterName $Name -PortPrefix $PortPrefix -EA Stop
Set-PrintConfiguration -DuplexingMode OneSided -Color $false -PrinterName $Name
}
Catch {
Write-Host -ForegroundColor Red $Error[0].ToString()
}