First commit
This commit is contained in:
commit
129ff2e587
5 changed files with 182 additions and 0 deletions
21
Add-Printer.ps1
Executable file
21
Add-Printer.ps1
Executable file
|
@ -0,0 +1,21 @@
|
|||
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()
|
||||
}
|
Reference in a new issue