目标:在 Windows 2012 R2 打印服务器上自动安装打印机的 x64 和 x32 驱动程序。
信息:到目前为止,我已经能够毫无问题地安装 x64 打印驱动程序。我在现有打印机上安装 x32 的尝试如下:
# - Set the driver name
$driverName = "HP Universal Printing PCL 6"
# - Get a list of printers that already have x64 drivers installed
$printers = get-Printer | where {$_.drivername -eq $driverName}
Foreach ($printer in $printers) {
# - This is the only way I could think to get the x32 print driver. It is already installed on the system with pnputil
$driver32 = get-printerdriver | where {$_.name -eq $driverName -and $_.printerenvironment -eq "Windows NT x86"}
# -- Turn off the share so we can add the driver.
$sharename = get-printer -name $printer | select -expand ShareName
set-printer -name $printer -Shared $false -confirm:$false
# -- This does not work. The set-printer cmdlet does not accept pipeline input.
$driver32 | set-printer -name $printer -confirm:$false
# -- Re-share the printer.
set-printer -name $printer -Shared $true -Sharename $sharename
}
问题:由于 Set-Printer 不接受管道输入,我想不出其他方法来告诉它要安装哪个驱动程序。x32 和 x64 驱动程序名称相同,所以我不知道如何使用 -DriverName 参数进行区分。