2013-11-26 130 views
0

这是我希望用一些简单的PowerShell来解决部署问题:编程方式更新网络打印机驱动程序

做32位的Windows XP在64位Windows 7迁移,USMT是 迁移所有网络打印机,这是伟大的。由于驱动程序 显然不正确,驱动程序需要手动升级(右键单击打印机 - >更新驱动程序) 。

此操作是否存在WMI函数或Powershell cmdlet?我似乎无法找到任何 文档!由于我们的USMT任务序列与 部署分开,并且在迁移的用户环境下运行,我相信它 可以工作。如果我可以得到正确的语法,那么在TS的末尾添加一个Powershell 脚本将是完美的。

我基本上正在寻找与右键单击打印机并单击“更新驱动程序”具有相同结果的功能。我已经在MDT论坛发布了这个帖子,因为我认为这可能更合适!

我看过Win32_Printer类,但看起来并不像我所需要的。

+0

您是否尝试过只映射打印机,看它是否会查询正确的打印机驱动程序?这就是我们为6000台机器和数百台打印机所做的所有工作...... \ –

回答

0

我怎么理解它,做一个RC->更新驱动程序并不是真正的管理打印驱动程序的正确方法。

更新驱动程序旨在将驱动程序从版本X更新到下一个版本Y,而不是将驱动程序从Win XP驱动程序更改为Win 7驱动程序的正确方法(即,如果XP驱动程序版本为1.0 ,而Win 7驱动程序在1.0,则运行更新驱动程序将不会执行任何操作,因为版本将相同)。

#1和最好的选择是使用PowerShell删除打印机,并重新添加它们(然后将安装W​​indows 7驱动程序)。这样你就可以保证他们会工作。

该脚本将是这样的:

#Get list of all the printers on the machine 
$printers = gwmi win32_printer 

#Save default Printer 
$DefaultPrinter = $printers | where{$_.Default} | Select ShareName 

#Create a list of all the printers we want to delete (in this case I am deleting all network printers) 
$PrintersToDelete = $printers | where{$_.Network -eq $true} 

#Create a list of all the printers we want to add (in this case, all network printers I just deleted) 
$PrintersToAdd = $printers | where{$_.Network -eq $true} | Select Name 

#Delete the printers I want to delete 
$PrintersToDelete | foreach{$_.delete()} 

#Add back all printers we want to add 
$PrintersToAdd | foreach{(New-Object -ComObject WScript.Network).AddWindowsPrinterConnection($_.Name)} 

#Get list of all the new printers on the machine 
$printers = gwmi win32_printer 

#Set the default printer 
$NewDefaultPrinter = $printers | where{$_.DeviceID -match $DefaultPrinter} 
$NewDefaultPrinter.SetDefaultPrinter() 
+0

我已经结束了在TS的末尾编写脚本以完全删除打印机。但我认为你错误地认为RC - > Update驱动程序是错误的。无论实际的版本比较如何,将该更新单击到由服务器提供的最新驱动程序。 – mhouston100

相关问题