title: Create Printer Powershell
body: <p>Am having major difficulties getting a script I am working on to to successfully create a Printer.  I have so far managed to get the Printer Ports created successfully but it always errors with the Printer creation.  </p>
  
  <p>The CSV file where it is picking the information up from looks like this:</p>
  
  <pre><code>PrinterName,PrinterPort,IPAddress,Location,Comment,PrintDriver,
  Testprint1,Testport1,10.10.10.10,IT_Test,Test_1,HP LaserJet 4200 PCL 5e,
  </code></pre>
  
  <p>The error message I get is this:</p>
  
  <pre><code>Exception calling "Put" with "0" argument(s): "Generic failure "
  At C:\myversion.ps1:53 char:19
  + $objNewPrinter.Put &lt;&lt;&lt;&lt; () 
      + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
      + FullyQualifiedErrorId : DotNetMethodException
  </code></pre>
  
  <p>The code I am using is this:</p>
  
  <pre><code>trap { $error[0].Exception | get-member } $objNewPrinter.Put()
  
  Write-Host ("`tCreating " + $strPrinterName.Count + " Printer's`t") 
  $objPrint = [WMICLASS]"\\timvista\ROOT\cimv2:Win32_Printer"   
  $objPrint.psbase.scope.options.EnablePrivileges = $true 
  
  ## Loop through and create each printer 
  For($i=0; $i -lt $PrinterName.count; $i++) 
  { 
  $objNewPrinter = $objPrint.createInstance() 
  $objNewPrinter.DeviceID = $PrinterName[$i] ## This is the printer name 
  $objNewPrinter.DriverName = $PrintDriver[$i] 
  $objNewPrinter.PortName = $PrinterPort[$i] 
  $objNewPrinter.Location = $Location[$i] 
  $objNewPrinter.Comment = $Comment[$i] 
  $objNewPrinter.ShareName = $PrinterName[$i] 
  $objNewPrinter.Put() 
  $objPrint
  ## Add Security group 
  ## Not completed yet 
  } 
  </code></pre>
  
  <p>Does anyone have any thoughts about what a generic failure is and how to go about troubleshooting it?  </p>