Seite 1 von 1

[GELÖST] Skriptbereitstellung auf WAPT

Veröffentlicht: 5. Dez. 2024 - 15:53 ​​Uhr
aus Wissensdurst
- Installierte WAPT-Version: 2.5
- Server-Betriebssystem: Linux 22.04
- Betriebssystem des Administrations-/Paketerstellungsrechners: Windows Server 2016

Hallo,
ich verwende die Discovery-Version und möchte wissen, ob es eine Möglichkeit gibt, Skripte (.ps1, .bat usw.) auf Agentenrechnern bereitzustellen? Falls ja, gibt es dazu eine Dokumentation? Ich konnte online nichts dazu finden.
Vielen Dank!

Betreff: Skriptbereitstellung auf WAPT

Veröffentlicht: 6. Dez. 2024 - 14:17 Uhr
von Blemoire
Hallo,
dieses Skript wird mit den Befehlen `run()` oder `run_not_fatal()` für Batchdateien und mit `run_powershell`, `run_powershell_from_file()` oder `run_powershell_script()` für PS1-Dateien ausgeführt.
https://www.wapt.fr/apidoc/wapt-2.5/win ... elpers.run

Schönen Tag noch,
Bertrand

Betreff: Skriptbereitstellung auf WAPT

Veröffentlicht: 6. Dez. 2024 - 16:53 Uhr
aus Wissensdurst
blemoigne schrieb: 6. Dez. 2024 - 14:17 Uhr Hallo,
es funktioniert mit den Befehlen `run()` oder `run_not_fatal()` für Batchdateien und `run_powershell()`, `run_powershell_from_file()` oder `run_powershell_script()` für PS1-Dateien.
https://www.wapt.fr/apidoc/wapt-2.5/win ... elpers.run

Schönen Tag noch,
Bertrand
Hallo Bertrand,
Entschuldigen Sie, falls meine Fragen dumm erscheinen und die Antworten Ihnen offensichtlich vorkommen.
Ich bin ein absoluter Anfänger im Umgang mit der Software und würde gerne ein paar Details mehr erfahren, um ein Skript ausführen zu können.
Muss ich für diese Art von Arbeit eine leere Paketvorlage in der WAPT-Konsole generieren?
- Wie (oder wo) kann ich ein Paket über die Kommandozeile bearbeiten?
Danke !

Betreff: Skriptbereitstellung auf WAPT

Veröffentlicht: 6. Dez. 2024 - 18:01 Uhr
von Blemoire
Zuerst benötigen Sie eine installierte Entwicklungsumgebung:
https://www.wapt.fr/fr/doc/wapt-create- ... pt-console.

Anschließend erstellen Sie ein leeres Paket. Standardmäßig befindet sich das Entwicklungsverzeichnis unter c:\waptdev.
Dort können Sie dann die Skripte ablegen.

Schönes Wochenende,
Bertrand

Betreff: Skriptbereitstellung auf WAPT

Veröffentlicht: 9. Dez. 2024 - 16:01 Uhr
aus Wissensdurst
blemoigne schrieb: 6. Dez. 2024 - 18:01 Uhr Zuerst müssen Sie sicherstellen, dass Sie eine Entwicklungsumgebung installiert haben:
https://www.wapt.fr/fr/doc/wapt-create- ... pt-console

Anschließend müssen Sie ein leeres Paket erstellen. Standardmäßig befindet sich das Verzeichnis für das Entwicklungspaket unter c:\waptdev.
Sie können die Skripte in dieses Paketverzeichnis legen.

Schönes Wochenende,
Bertrand
Ich habe eine .bat-Datei erfolgreich mit folgendem Befehl bereitgestellt:

Code: Alle auswählen

def install():
    run(r"mon_script.bat")
Die PowerShell-Datei aus dem Repository funktioniert leider nicht. Ich bin folgendermaßen vorgegangen; könnten Sie bitte überprüfen, ob das korrekt ist?

Code: Alle auswählen

def install():
    run_powershell(r"mon_script.ps1")
Danke !

Betreff: Skriptbereitstellung auf WAPT

Veröffentlicht: 9. Dez. 2024 - 16:23 Uhr
von fschelfaut
Guten Morgen,

Die Funktion run_powershell() Warten auf die Ausführung eines PowerShell-Befehls.
Um ein Skript auszuführen *.ps1Sie müssen die dafür vorgesehene Funktion verwenden: run_powershell_script().

Hier einige Anwendungsbeispiele:

Code: Alle auswählen

def install():
    run_powershell_script("mon_script.ps1")
    run_powershell('Write-Host "Je suis un test"')
Alle in einem WAPT-Paket verwendbaren Funktionen sind dokumentiert Hier
- https://www.wapt.fr/apidoc/wapt-2.6/win ... ell_script
- https://www.wapt.fr/apidoc/wapt-2.6/win ... powershell

Flavien

Betreff: Skriptbereitstellung auf WAPT

Veröffentlicht: 10. Dez. 2024 - 11:26 Uhr
aus Wissensdurst
Guten Morgen,

Ich erhalte immer wieder Fehler im Zusammenhang mit der Bereitstellung von .ps1-Skripten :(
Im leeren Paket unter C:\waptdev, wo ich meine test.ps1-Skriptdatei abgelegt habe:

Code: Alle auswählen

$sourceFilePath = "\\lan.xxx.xxx\NETLOGON\GPOs\Scripts\TEST WAPT\test.txt"
$destinationFilePath = "C:\test.txt"

if (Test-Path -Path $destinationFilePath) {
    exit
} else {
    Copy-Item -Path $sourceFilePath -Destination $destinationFilePath -Force
}
Hier ist der Code in setup.py:

Code: Alle auswählen

# -*- coding: utf-8 -*-
from setuphelpers import *

def install():
    run_powershell_script(r"test.ps1")
Als Nächstes habe ich das Paket mit folgendem Befehl in der Eingabeaufforderung erstellt:

Code: Alle auswählen

wapt-get build-package C:\waptdev\idvet-testscript_1.0.0_x64_Windows_PROD-wapt
Im leeren Paket habe ich die Architektur auf x64 und das Zielbetriebssystem auf Windows konfiguriert.
Beim Deployment erscheint folgender Fehlercode:

Code: Alle auswählen

https://xxx.xxx.xxx.xxx/wapt/idvet-testscript_1.0.0-0_x64_windows_PROD.wapt : 5522 / 5522 (100%) (15 KB/s)
Erreur lors de l'installation de ['idvet-testscript(=1.0.0-0)']: erreurs dans les paquets [[PackageRequest(package='idvet-testscript',version=(Version('1.0.0.0'), 0),architectures=['x64'],locales=['fr'],maturities=['PROD'],tags=['windows-10', 'win-10', 'w-10', 'windows10', 'win10', 'w10', 'windows', 'win', 'w'],min_os_version=Version('10.0.19045'),max_os_version=Version('10.0.19045')), PackageEntry('idvet-testscript','1.0.0-0' architecture='x64',maturity='PROD',target_os='windows'), 'Traceback (most recent call last):\n  File "C:\\Program Files (x86)\\wapt\\setuphelpers_windows.py", line 1237, in run_powershell\n    return json.loads(\'\\n\'.join(lines))\n  File "json\\__init__.py", line 357, in loads\n  File "json\\decoder.py", line 337, in decode\n  File "json\\decoder.py", line 355, in raw_decode\njson.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File "C:\\Program Files (x86)\\wapt\\common.py", line 5348, in install\n    result = self.install_wapt(p.localpath,\n  File "C:\\Program Files (x86)\\wapt\\common.py", line 4328, in install_wapt\n    raise e\n  File "C:\\Program Files (x86)\\wapt\\common.py", line 4235, in install_wapt\n    exitstatus = setup.install()\n  File "C:\\Windows\\TEMP\\wapt8smn47lj\\setup.py", line 5, in install\n  File "C:\\Program Files (x86)\\wapt\\setuphelpers_windows.py", line 1266, in run_powershell_script\n    return run_powershell(\'(invoke-expression -Command "%s")\' % script_filename, output_format, **kwargs)\n  File "C:\\Program Files (x86)\\wapt\\setuphelpers_windows.py", line 1239, in run_powershell\n    raise ValueError(\'%s returned non json data:\\n%s\\n%s\' % (cmd, result, e))\nValueError: "C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -OutputFormat text -EncodedCommand "JABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAiAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAIgAKACgAaQBuAHYAbwBrAGUALQBlAHgAcAByAGUAcwBzAGkAbwBuACAALQBDAG8AbQBtAGEAbgBkACAAIgB0AGUAcwB0AC4AcABzADEAIgApACAAIAB8ACAAQwBvAG4AdgBlAHIAdABUAG8ALQBKAHMAbwBuACAA"  returned non json data:\n#< CLIXML\r\n<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><S S="Error">test.ps1 : Le terme «test.ps1» 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:1 : 1_x000D__x000A_</S><S S="Error">+ test.ps1_x000D__x000A_</S><S S="Error">+ ~~~~~~~~_x000D__x000A_</S><S S="Error">    + CategoryInfo          : ObjectNotFound: (test.ps1:String) [], CommandNotFoundException_x000D__x000A_</S><S S="Error">    + FullyQualifiedErrorId : CommandNotFoundException_x000D__x000A_</S><S S="Error"> _x000D__x000A_</S></Objs>\nExpecting value: line 1 column 1 (char 0)\n']]
Traceback (most recent call last):
  File "<string>", line 1943, in run
  File "C:\Program Files (x86)\wapt\waptservice\waptservice_common.py", line 737, in run
    self._run()
  File "C:\Program Files (x86)\wapt\waptservice\waptservice_common.py", line 1341, in _run
    raise Exception(_('Error during install of {}: errors in packages {}').format(
Exception: Erreur lors de l'installation de ['idvet-testscript(=1.0.0-0)']: erreurs dans les paquets [[PackageRequest(package='idvet-testscript',version=(Version('1.0.0.0'), 0),architectures=['x64'],locales=['fr'],maturities=['PROD'],tags=['windows-10', 'win-10', 'w-10', 'windows10', 'win10', 'w10', 'windows', 'win', 'w'],min_os_version=Version('10.0.19045'),max_os_version=Version('10.0.19045')), PackageEntry('idvet-testscript','1.0.0-0' architecture='x64',maturity='PROD',target_os='windows'), 'Traceback (most recent call last):\n  File "C:\\Program Files (x86)\\wapt\\setuphelpers_windows.py", line 1237, in run_powershell\n    return json.loads(\'\\n\'.join(lines))\n  File "json\\__init__.py", line 357, in loads\n  File "json\\decoder.py", line 337, in decode\n  File "json\\decoder.py", line 355, in raw_decode\njson.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File "C:\\Program Files (x86)\\wapt\\common.py", line 5348, in install\n    result = self.install_wapt(p.localpath,\n  File "C:\\Program Files (x86)\\wapt\\common.py", line 4328, in install_wapt\n    raise e\n  File "C:\\Program Files (x86)\\wapt\\common.py", line 4235, in install_wapt\n    exitstatus = setup.install()\n  File "C:\\Windows\\TEMP\\wapt8smn47lj\\setup.py", line 5, in install\n  File "C:\\Program Files (x86)\\wapt\\setuphelpers_windows.py", line 1266, in run_powershell_script\n    return run_powershell(\'(invoke-expression -Command "%s")\' % script_filename, output_format, **kwargs)\n  File "C:\\Program Files (x86)\\wapt\\setuphelpers_windows.py", line 1239, in run_powershell\n    raise ValueError(\'%s returned non json data:\\n%s\\n%s\' % (cmd, result, e))\nValueError: "C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -OutputFormat text -EncodedCommand "JABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAiAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAIgAKACgAaQBuAHYAbwBrAGUALQBlAHgAcAByAGUAcwBzAGkAbwBuACAALQBDAG8AbQBtAGEAbgBkACAAIgB0AGUAcwB0AC4AcABzADEAIgApACAAIAB8ACAAQwBvAG4AdgBlAHIAdABUAG8ALQBKAHMAbwBuACAA"  returned non json data:\n#< CLIXML\r\n<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><S S="Error">test.ps1 : Le terme «test.ps1» 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:1 : 1_x000D__x000A_</S><S S="Error">+ test.ps1_x000D__x000A_</S><S S="Error">+ ~~~~~~~~_x000D__x000A_</S><S S="Error">    + CategoryInfo          : ObjectNotFound: (test.ps1:String) [], CommandNotFoundException_x000D__x000A_</S><S S="Error">    + FullyQualifiedErrorId : CommandNotFoundException_x000D__x000A_</S><S S="Error"> _x000D__x000A_</S></Objs>\nExpecting value: line 1 column 1 (char 0)\n']]

Exception: Erreur lors de l'installation de ['idvet-testscript(=1.0.0-0)']: erreurs dans les paquets [[PackageRequest(package='idvet-testscript',version=(Version('1.0.0.0'), 0),architectures=['x64'],locales=['fr'],maturities=['PROD'],tags=['windows-10', 'win-10', 'w-10', 'windows10', 'win10', 'w10', 'windows', 'win', 'w'],min_os_version=Version('10.0.19045'),max_os_version=Version('10.0.19045')), PackageEntry('idvet-testscript','1.0.0-0' architecture='x64',maturity='PROD',target_os='windows'), 'Traceback (most recent call last):\n  File "C:\\Program Files (x86)\\wapt\\setuphelpers_windows.py", line 1237, in run_powershell\n    return json.loads(\'\\n\'.join(lines))\n  File "json\\__init__.py", line 357, in loads\n  File "json\\decoder.py", line 337, in decode\n  File "json\\decoder.py", line 355, in raw_decode\njson.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File "C:\\Program Files (x86)\\wapt\\common.py", line 5348, in install\n    result = self.install_wapt(p.localpath,\n  File "C:\\Program Files (x86)\\wapt\\common.py", line 4328, in install_wapt\n    raise e\n  File "C:\\Program Files (x86)\\wapt\\common.py", line 4235, in install_wapt\n    exitstatus = setup.install()\n  File "C:\\Windows\\TEMP\\wapt8smn47lj\\setup.py", line 5, in install\n  File "C:\\Program Files (x86)\\wapt\\setuphelpers_windows.py", line 1266, in run_powershell_script\n    return run_powershell(\'(invoke-expression -Command "%s")\' % script_filename, output_format, **kwargs)\n  File "C:\\Program Files (x86)\\wapt\\setuphelpers_windows.py", line 1239, in run_powershell\n    raise ValueError(\'%s returned non json data:\\n%s\\n%s\' % (cmd, result, e))\nValueError: "C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -OutputFormat text -EncodedCommand "JABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAiAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAIgAKACgAaQBuAHYAbwBrAGUALQBlAHgAcAByAGUAcwBzAGkAbwBuACAALQBDAG8AbQBtAGEAbgBkACAAIgB0AGUAcwB0AC4AcABzADEAIgApACAAIAB8ACAAQwBvAG4AdgBlAHIAdABUAG8ALQBKAHMAbwBuACAA"  returned non json data:\n#< CLIXML\r\n<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><S S="Error">test.ps1 : Le terme «test.ps1» 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:1 : 1_x000D__x000A_</S><S S="Error">+ test.ps1_x000D__x000A_</S><S S="Error">+ ~~~~~~~~_x000D__x000A_</S><S S="Error">    + CategoryInfo          : ObjectNotFound: (test.ps1:String) [], CommandNotFoundException_x000D__x000A_</S><S S="Error">    + FullyQualifiedErrorId : CommandNotFoundException_x000D__x000A_</S><S S="Error"> _x000D__x000A_</S></Objs>\nExpecting value: line 1 column 1 (char 0)\n']]
Traceback (most recent call last):
  File "<string>", line 1943, in run
  File "C:\Program Files (x86)\wapt\waptservice\waptservice_common.py", line 737, in run
    self._run()
  File "C:\Program Files (x86)\wapt\waptservice\waptservice_common.py", line 1341, in _run
    raise Exception(_('Error during install of {}: errors in packages {}').format(
Exception: Erreur lors de l'installation de ['idvet-testscript(=1.0.0-0)']: erreurs dans les paquets [[PackageRequest(package='idvet-testscript',version=(Version('1.0.0.0'), 0),architectures=['x64'],locales=['fr'],maturities=['PROD'],tags=['windows-10', 'win-10', 'w-10', 'windows10', 'win10', 'w10', 'windows', 'win', 'w'],min_os_version=Version('10.0.19045'),max_os_version=Version('10.0.19045')), PackageEntry('idvet-testscript','1.0.0-0' architecture='x64',maturity='PROD',target_os='windows'), 'Traceback (most recent call last):\n  File "C:\\Program Files (x86)\\wapt\\setuphelpers_windows.py", line 1237, in run_powershell\n    return json.loads(\'\\n\'.join(lines))\n  File "json\\__init__.py", line 357, in loads\n  File "json\\decoder.py", line 337, in decode\n  File "json\\decoder.py", line 355, in raw_decode\njson.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File "C:\\Program Files (x86)\\wapt\\common.py", line 5348, in install\n    result = self.install_wapt(p.localpath,\n  File "C:\\Program Files (x86)\\wapt\\common.py", line 4328, in install_wapt\n    raise e\n  File "C:\\Program Files (x86)\\wapt\\common.py", line 4235, in install_wapt\n    exitstatus = setup.install()\n  File "C:\\Windows\\TEMP\\wapt8smn47lj\\setup.py", line 5, in install\n  File "C:\\Program Files (x86)\\wapt\\setuphelpers_windows.py", line 1266, in run_powershell_script\n    return run_powershell(\'(invoke-expression -Command "%s")\' % script_filename, output_format, **kwargs)\n  File "C:\\Program Files (x86)\\wapt\\setuphelpers_windows.py", line 1239, in run_powershell\n    raise ValueError(\'%s returned non json data:\\n%s\\n%s\' % (cmd, result, e))\nValueError: "C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -OutputFormat text -EncodedCommand "JABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAiAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAIgAKACgAaQBuAHYAbwBrAGUALQBlAHgAcAByAGUAcwBzAGkAbwBuACAALQBDAG8AbQBtAGEAbgBkACAAIgB0AGUAcwB0AC4AcABzADEAIgApACAAIAB8ACAAQwBvAG4AdgBlAHIAdABUAG8ALQBKAHMAbwBuACAA"  returned non json data:\n#< CLIXML\r\n<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><S S="Error">test.ps1 : Le terme «test.ps1» 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:1 : 1_x000D__x000A_</S><S S="Error">+ test.ps1_x000D__x000A_</S><S S="Error">+ ~~~~~~~~_x000D__x000A_</S><S S="Error">    + CategoryInfo          : ObjectNotFound: (test.ps1:String) [], CommandNotFoundException_x000D__x000A_</S><S S="Error">    + FullyQualifiedErrorId : CommandNotFoundException_x000D__x000A_</S><S S="Error"> _x000D__x000A_</S></Objs>\nExpecting value: line 1 column 1 (char 0)\n']]
Ich möchte darauf hinweisen, dass ich das manuelle Starten des Skripts auf dem Host-PC getestet habe und es einwandfrei funktioniert.
Ich habe es auch mit dem Argument run_powershell_script(r"test.ps1", output_format='text') getestet, ohne zu wissen, was es genau bewirkt. Das Paket wird problemlos gestartet, aber das Skript funktioniert nicht auf dem Host.

Haben Sie vielleicht Ideen zu diesem Problem, die mir weiterhelfen könnten? Vielen Dank!

Betreff: Skriptbereitstellung auf WAPT

Veröffentlicht: 11. Dez. 2024 - 13:28 Uhr
aus Wissensdurst
Guten Morgen,

Ich habe endlich eine Lösung gefunden, um das Skript auszuführen. Hier ist mein Code in der setup.py-Datei zum Ausführen des test.ps1-Skripts, das sich im leeren WAPT-Paket befindet:

Code: Alle auswählen

# -*- coding: utf-8 -*-
from setuphelpers import *
import os  # Import du module os pour gérer les chemins

def install():
    """
    Cette fonction est exécutée lors de l'installation du paquet.
    """
    current_dir = os.getcwd()
    script_path = os.path.join(current_dir, "test.ps1")

    # Exécuter le script PowerShell
    run(f"powershell.exe -ExecutionPolicy Bypass -File \"{script_path}\"")

def uninstall():
    """
    Cette fonction peut être utilisée pour désinstaller si nécessaire.
    """
    print("Uninstallation is not defined for this package.")
Vielen Dank und einen schönen Tag noch!