Bonjour,
J'ai récupéré un script sur le net permettant d'installer des imprimantes à distance. Mais bon vu mon niveau je galère pour l'adapter. Donc je commence déjà par essayer d'installer une imprimante sur mon propre poste avec le minimum de variables. Même comme ça plantage. Je vois pas ce qui bloque?
tout va bien jusqu'à la création du port ip qui ce fait bien ensuite, ça coince pour l'installation du drivers.
-J'ai vérifié le chemin du dossier des drivers ainsi que l'orthographe du .inf
-Je lance le ps1 par un bat en tant qu'admin donc ça doit pas être une histoire de sécu
Code PowerShell : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74 #################################################### # Change these values to the appropriate values in your environment $PrinterIP = Read-Host -Prompt 'Indiquer IP IMPRIMANTE' $PrinterPort = "9100" $PrinterPortName =$PrinterIP $DriverName = "KONICA" $DriverPath = "c:\outils\KONICA" $DriverInf = "c:\outils\KONICA\KOAXWJ__.INF" $PrinterCaption = "KONICA MINOLTA C308" #################################################### ### ComputerList Option 1 ### # $ComputerList = @("lana", "lisaburger") #$ComputerList = @() #Import-Csv "$PSScriptRoot\Ordinateurs.csv" | ` #% {$ComputerList += $_.Computer} Pause Function CreatePrinterPort { param ($PrinterIP, $PrinterPort, $PrinterPortName) $wmi = [wmiclass]"\root\cimv2:win32_tcpipPrinterPort" $wmi.psbase.scope.options.enablePrivileges = $true $Port = $wmi.createInstance() $Port.name = $PrinterPortName $Port.hostAddress = $PrinterIP $Port.portNumber = $PrinterPort $Port.SNMPEnabled = $false $Port.Protocol = 1 $Port.put() } pause Function InstallPrinterDriver { Param ($DriverName, $DriverPath, $DriverInf) $wmi = [wmiclass]"\Root\cimv2:Win32_PrinterDriver" $wmi.psbase.scope.options.enablePrivileges = $true $wmi.psbase.Scope.Options.Impersonation = ` [System.Management.ImpersonationLevel]::Impersonate $Driver = $wmi.CreateInstance() $Driver.Name = $DriverName $Driver.DriverPath = $DriverPath $Driver.InfName = $DriverInf $wmi.AddPrinterDriver($Driver) $wmi.Put() } pause Function CreatePrinter { param ($PrinterCaption, $PrinterPortName, $DriverName) $wmi = ([WMIClass]"\Root\cimv2:Win32_Printer") $Printer = $wmi.CreateInstance() $Printer.Caption = $PrinterCaption $Printer.DriverName = $DriverName $Printer.PortName = $PrinterPortName $Printer.DeviceID = $PrinterCaption $Printer.Put() } pause CreatePrinterPort -PrinterIP $PrinterIP -PrinterPort $PrinterPort ` -PrinterPortName $PrinterPortName InstallPrinterDriver -DriverName $DriverName -DriverPath ` $DriverPath -DriverInf $DriverInf CreatePrinter -PrinterPortName $PrinterPortName -DriverName ` $DriverName -PrinterCaption $PrinterCaption pause ####################################################
Exception lors de l'appel de «*Put*» avec «*0*» argument(s)*: «*Échec générique *» Au caractère E:\PrinterInstallerKonica\PrinterInstallerKonica - Copie de travail2.ps1:60 : 5 + $Printer.Put() + ~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: ( : ) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException
Merci de votre aide.
Partager