3
스크립트를 만드는 데 큰 어려움을 겪고 있습니다. 프린터를 성공적으로 만들기 위해 노력하고 있습니다. 지금까지 프린터 포트를 성공적으로 만들 수 있었지만 프린터 생성시 항상 오류가있었습니다.프린터 Powershell 만들기
은 다음과 같습니다로부터 정보를 따기입니다 CSV 파일 :
:Exception calling "Put" with "0" argument(s): "Generic failure "
At C:\myversion.ps1:53 char:19
+ $objNewPrinter.Put <<<<()
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
내가 사용하고 코드는 이것이다 :
이PrinterName,PrinterPort,IPAddress,Location,Comment,PrintDriver,
Testprint1,Testport1,10.10.10.10,IT_Test,Test_1,HP LaserJet 4200 PCL 5e,
내가 오류 메시지가 이것이다
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
}
일반 실패의 원인에 대한 의견이 있거나 문제 해결 방법에 대해 의견이있는 사람이 있습니까? 땡?
기존 프린터 드라이버의 정확한 이름을 나열하는 방법이 있습니까? 지금까지 나는 Printer Control Panel 애플릿의 Server Properties 섹션에서 Driver 탭을 사용 해왔다. 우리가 사용하게 될 실제 프린터 이름에 대한 테스트도 수행 할 것입니다. –
'$ Class = "win32_printer" Get-WmiObject -class $ 클래스 | ft 이름, drivername -auto' – RRUZ