Avatar of Karl Malone
Karl MaloneFlag for United States of America

asked on 

Win32_Printer Put() Throwing a "Generic Failure" Error

We've been trying to deploy a TCP/IP printer to a non-AD-joined machine using PowerShell.

The function we're using is:

Function CreatePrinter {
    $wmi = ([WMIClass]"\\$ComputerName\Root\cimv2:Win32_Printer")
    $Printer = $wmi.CreateInstance()
    $Printer.CreationClassName = "Win32_Printer"
    $Printer.Caption = $PrinterCaption
    $Printer.DriverName = $DriverName
    $Printer.PortName = $PrinterPortName
    $Printer.DeviceID = $PrinterCaption
    $Printer.Put()
}

Open in new window


However, when running Put(), we receive the following error:

Exception calling "Put" with "0" argument(s): "Generic failure "

We've made sure the driver is pointing correctly, the driver is installed, and all of the required parameters are filled in. Interestingly, this works on a local Windows 10 machine using a different printer, but when trying on a different Windows 7 machine using a different printer, it fails.

Any and all help would be greatly appreciated.
PowershellPrinters and ScannersWindows 10Windows OS* Drivers

Avatar of undefined
Last Comment
McKnife
Avatar of Cliff Galiher
Cliff Galiher
Flag of United States of America image

If your goal is to use powershell, why aren't you using the add-printer cmdlet? WMI via powershell can be clunky and you really have to dig into MSDN to get the API right.
Avatar of McKnife
McKnife
Flag of Germany image

And then there's native GPO printer deployment which works stable and is very convenient... why use powershell?
Avatar of Karl Malone
Karl Malone
Flag of United States of America image

ASKER

Cliff Galiher, the Add-Printer cmdlet doesn't exist in Windows 7. The goal of the script is to be flexible and executable on any non-AD machine, 7 or 10, that we need to deploy printers on, which is why we've resorted to trying to use WMI.

McKnife, as stated in the original post, the machine is not joined to Active Directory.
ASKER CERTIFIED SOLUTION
Avatar of Cliff Galiher
Cliff Galiher
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of McKnife
McKnife
Flag of Germany image

Sorry, for missing that detail.

An idea: your deployment, is it to several machines? Why not do it from remote?
https://powershell.org/forums/topic/powershell-v3-on-win7/ shows, how someone uses an OS (there: win8.1) that has the add-printer cmdlet to install a printer on server 2008 R2 from remote - I guess it will work the same way against a remote Win7.
Avatar of McKnife
McKnife
Flag of Germany image

Just for me: was my suggestion tried? It looked very promising and easy at the same time.
Windows OS
Windows OS

This topic area includes legacy versions of Windows prior to Windows 2000: Windows 3/3.1, Windows 95 and Windows 98, plus any other Windows-related versions including Windows Mobile.

129K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo