I have a script I am using from Kris Powell. To install printers. From what I can see I need to call these functions before it will actually install a printer via IP Address. any ideas on how i do this?
Here is what I have
$PrinterIP = “192.168.141.20” $PrinterPort = “9100” $PrinterPortName = “IP_192.168.141.20” + $PrinterIP $DriverName = “Ricoh Aficio MP C6000 PS” $DriverPath = “\\bh-miworks-srv2\PrintDrivers\Ricoh MP c6501 e7200 Dockside Color\Win 10 PS\English\Prntdrvr\Ps_drvr\Win_2K_XP_VISTA” $DriverInf = “\\bh-miworks-srv2\PrintDrivers\Ricoh MP c6501 e7200 Dockside Color\Win 10 PS\English\Prntdrvr\Ps_drvr\Win_2K_XP_VISTA\oemsetup.inf” $PrinterCaption = “BH DockSide Color” Function CreatePrinterPort { param ($PrinterIP, $PrinterPort, $PrinterPortName, $ComputerName) $wmi = [wmiclass]”\\$ComputerName\root\cimv2:win32_tcpipPrinterPort” $wmi.psbase.scope.options.enablePrivileges = $true $Port = $wmi.createInstance() $Port.name = $"192.168.141.20" $Port.hostAddress = $"192.168.141.20" $Port.portNumber = $9100 $Port.SNMPEnabled = $false $Port.Protocol = 1 $Port.put_ } Function InstallPrinterDriver { Param ($DriverName, $DriverPath, $DriverInf, $ComputerName) $wmi = [wmiclass]”\\$ComputerName\Root\cimv2:Win32_PrinterDriver” $wmi.psbase.scope.options.enablePrivileges = $true $wmi.psbase.Scope.Options.Impersonation = ` [System.Management.ImpersonationLevel]::Impersonate $Driver = $wmi.CreateInstance() $Driver.Name = $"Ricoh Aficio MP C6000 PS" $Driver.DriverPath = $"\\bh-miworks-srv2\PrintDrivers\Ricoh MP c6501 e7200 Dockside Color\Win 10 PS\English\Prntdrvr\Ps_drvr\Win_2K_XP_VISTA" $Driver.InfName = $"\\bh-miworks-srv2\PrintDrivers\Ricoh MP c6501 e7200 Dockside Color\Win 10 PS\English\Prntdrvr\Ps_drvr\Win_2K_XP_VISTA\oemsetup.inf" $wmi.AddPrinterDriver($Driver) $wmi.Put_ } Function CreatePrinter { param ($PrinterCaption, $PrinterPortName, $DriverName, $ComputerName) $wmi = ([WMIClass]”\\$ComputerName\Root\cimv2:Win32_Printer”) $Printer = $wmi.CreateInstance() $Printer.Caption = $"BH DockSide Color" $Printer.DriverName = $"Ricoh Aficio MP C6000 PS" $Printer.PortName = $"192.168.141.20" $Printer.DeviceID = $"DockSide Color" $Printer.Put_ }
Output is as follows
PS C:\windows\system32> C:\Users\christnerw\Desktop\printer test.ps1 PS C:\windows\system32>
So basically I am not getting any errors (Score)
Thanks