Nous venons d'exécuter chaque commande du script avec run_powershell
voici le code:
Code : Tout sélectionner
run_powershell('$OldServerName = "xxxxxxxx"')
run_powershell('$NewServerName = "yyyyyyyy"')
run_powershell('$CurrentPrinters = Get-WmiObject Win32_Printer | Where-Object {$_.Network -eq "true"} | Select-Object -ExpandProperty Name')
run_powershell('-WmiObject -Class Win32_Printer | Where-Object {$_.Network -eq "true"} | ForEach-Object {$_.delete()}')
run_powershell('$CurrentPrinters | ForEach-Object { $newprintername = $_.Replace( $OldServerName, $NewServerName ) Add-Printer -ConnectionName $newprintername}')
Lorsque je déploie le paquet sur une machine, nous avons des erreurs dans la console wapt
voici les erreurs:
Code : Tout sélectionner
Installing:
Traceback (most recent call last):
File "C:\Program Files (x86)\wapt\setuphelpers_windows.py", line 1080, in run_powershell
result = run(cmd,
File "C:\Program Files (x86)\wapt\waptutils.py", line 2091, in run
raise CalledProcessErrorOutput(proc.returncode, cmd, ''.join(output+return_stderr))
waptutils.CalledProcessErrorOutput: Command 'powershell -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -OutputFormat text -EncodedCommand "JABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAiAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAIgAKAC0AVwBtAGkATwBiAGoAZQBjAHQAIAAtAEMAbABhAHMAcwAgAFcAaQBuADMAMgBfAFAAcgBpAG4AdABlAHIAIAB8ACAAVwBoAGUAcgBlAC0ATwBiAGoAZQBjAHQAIAB7ACQAXwAuAE4AZQB0AHcAbwByAGsAIAAtAGUAcQAgACIAdAByAHUAZQAiAH0AIAB8ACAARgBvAHIARQBhAGMAaAAtAE8AYgBqAGUAYwB0ACAAewAkAF8ALgBkAGUAbABlAHQAZQAoACkAfQAgACAAfAAgAEMAbwBuAHYAZQByAHQAVABvAC0ASgBzAG8AbgAgAA==" ' returned non-zero exit status 1.
Output:#< CLIXML
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><S S="Error">-WmiObject : Le terme «-WmiObject» n'est pas reconnu comme nom d'applet de commande, fonction, fichier de script ou _x000D__x000A_</S><S S="Error">programme exécutable. Vérifiez l'orthographe du nom, ou si un chemin d'accès existe, vérifiez que le chemin d'accès _x000D__x000A_</S><S S="Error">est correct et réessayez._x000D__x000A_</S><S S="Error">Au caractère Ligne:2 : 1_x000D__x000A_</S><S S="Error">+ -WmiObject -Class Win32_Printer | Where-Object {$_.Network -eq "true" ..._x000D__x000A_</S><S S="Error">+ ~~~~~~~~~~_x000D__x000A_</S><S S="Error"> + CategoryInfo : ObjectNotFound: (-WmiObject:String) [], CommandNotFoundException_x000D__x000A_</S><S S="Error"> + FullyQualifiedErrorId : CommandNotFoundException_x000D__x000A_</S><S S="Error"> _x000D__x000A_</S></Objs>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files (x86)\wapt\common.py", line 3938, in install_wapt
exitstatus = setup.install()
File "C:\windows\TEMP\waptq24g89cv\setup.py", line 15, in install
File "C:\Program Files (x86)\wapt\setuphelpers_windows.py", line 1084, in run_powershell
raise CalledProcessErrorOutput(e.returncode, cmd, e.output)
waptutils.CalledProcessErrorOutput: Command 'powershell -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -OutputFormat text -EncodedCommand "JABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAiAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAIgAKAC0AVwBtAGkATwBiAGoAZQBjAHQAIAAtAEMAbABhAHMAcwAgAFcAaQBuADMAMgBfAFAAcgBpAG4AdABlAHIAIAB8ACAAVwBoAGUAcgBlAC0ATwBiAGoAZQBjAHQAIAB7ACQAXwAuAE4AZQB0AHcAbwByAGsAIAAtAGUAcQAgACIAdAByAHUAZQAiAH0AIAB8ACAARgBvAHIARQBhAGMAaAAtAE8AYgBqAGUAYwB0ACAAewAkAF8ALgBkAGUAbABlAHQAZQAoACkAfQAgACAAfAAgAEMAbwBuAHYAZQByAHQAVABvAC0ASgBzAG8AbgAgAA==" ' returned non-zero exit status 1.
Output:#< CLIXML
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><S S="Error">-WmiObject : Le terme «-WmiObject» n'est pas reconnu comme nom d'applet de commande, fonction, fichier de script ou _x000D__x000A_</S><S S="Error">programme exécutable. Vérifiez l'orthographe du nom, ou si un chemin d'accès existe, vérifiez que le chemin d'accès _x000D__x000A_</S><S S="Error">est correct et réessayez._x000D__x000A_</S><S S="Error">Au caractère Ligne:2 : 1_x000D__x000A_</S><S S="Error">+ -WmiObject -Class Win32_Printer | Where-Object {$_.Network -eq "true" ..._x000D__x000A_</S><S S="Error">+ ~~~~~~~~~~_x000D__x000A_</S><S S="Error"> + CategoryInfo : ObjectNotFound: (-WmiObject:String) [], CommandNotFoundException_x000D__x000A_</S><S S="Error"> + FullyQualifiedErrorId : CommandNotFoundException_x000D__x000A_</S><S S="Error"> _x000D__x000A_</S></Objs>
CalledProcessErrorOutput: Command 'powershell -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -OutputFormat text -EncodedCommand "JABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAiAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAIgAKAC0AVwBtAGkATwBiAGoAZQBjAHQAIAAtAEMAbABhAHMAcwAgAFcAaQBuADMAMgBfAFAAcgBpAG4AdABlAHIAIAB8ACAAVwBoAGUAcgBlAC0ATwBiAGoAZQBjAHQAIAB7ACQAXwAuAE4AZQB0AHcAbwByAGsAIAAtAGUAcQAgACIAdAByAHUAZQAiAH0AIAB8ACAARgBvAHIARQBhAGMAaAAtAE8AYgBqAGUAYwB0ACAAewAkAF8ALgBkAGUAbABlAHQAZQAoACkAfQAgACAAfAAgAEMAbwBuAHYAZQByAHQAVABvAC0ASgBzAG8AbgAgAA==" ' returned non-zero exit status 1.
Output:#< CLIXML
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><S S="Error">-WmiObject : Le terme «-WmiObject» n'est pas reconnu comme nom d'applet de commande, fonction, fichier de script ou _x000D__x000A_</S><S S="Error">programme exécutable. Vérifiez l'orthographe du nom, ou si un chemin d'accès existe, vérifiez que le chemin d'accès _x000D__x000A_</S><S S="Error">est correct et réessayez._x000D__x000A_</S><S S="Error">Au caractère Ligne:2 : 1_x000D__x000A_</S><S S="Error">+ -WmiObject -Class Win32_Printer | Where-Object {$_.Network -eq "true" ..._x000D__x000A_</S><S S="Error">+ ~~~~~~~~~~_x000D__x000A_</S><S S="Error"> + CategoryInfo : ObjectNotFound: (-WmiObject:String) [], CommandNotFoundException_x000D__x000A_</S><S S="Error"> + FullyQualifiedErrorId : CommandNotFoundException_x000D__x000A_</S><S S="Error"> _x000D__x000A_</S></Objs>
Cordialement,
Albin