[SOLVED] run_powershell

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Locked
florentR2
Messages: 100
Registration: February 13, 2020 - 5:23 PM

April 28, 2020 - 11:40 AM

Good morning,
I am unable to execute a PowerShell script.
I checked with get-executionpolicy to see if I was in RemoteSigned or Unrestricted mode

To better debug, I just put an "ls" in my test.ps1 file and I have the same problem.
No problem if I just run the command with

Code: Select all

run_powershell('ls')
I tried as well

Code: Select all

run_powershell('test.ps1')
run_powershell_from_file('test.ps1')
Did I miss something?

Here is the console output I get:

Code: Select all

2020-04-28 11:33:30,980 CRITICAL Fatal error in install script: CalledProcessErrorOutput: Command u'$ProgressPreference = "SilentlyContinue"\n(test.ps1) | ConvertTo-Json' 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">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:2 : 2_x000D__x000A_</S><S S="Error">+ (test.ps1) | ConvertTo-Json_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>:
Traceback (most recent call last):
  File "C:\Program Files (x86)\wapt\common.py", line 3823, in install_wapt
    exitstatus = setup.install()
  File "c:\waptdev\fl-bat-cmd-wapt\setup.py", line 10, in install
    run_powershell('test.ps1')
  File "C:\Program Files (x86)\wapt\setuphelpers_windows.py", line 933, in run_powershell
    raise CalledProcessErrorOutput(e.returncode,cmd,e.output)
CalledProcessErrorOutput: Command u'$ProgressPreference = "SilentlyContinue"\n(test.ps1) | ConvertTo-Json' 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">test.ps1 : Le terme \xabtest.ps1\xbb n'est pas reconnu comme nom d'applet de commande, fonction, fichier de script ou _x000D__x000A_</S><S S="Error">programme ex\xe9cutable. V\xe9rifiez l'orthographe du nom, ou si un chemin d'acc\xe8s existe, v\xe9rifiez que le chemin d'acc\xe8s _x000D__x000A_</S><S S="Error">est correct et r\xe9essayez._x000D__x000A_</S><S S="Error">Au caract\xe8re Ligne:2 : 2_x000D__x000A_</S><S S="Error">+ (test.ps1) | ConvertTo-Json_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>

FATAL ERROR : CalledProcessErrorOutput: Command u'$ProgressPreference = "SilentlyContinue"\n(test.ps1) | ConvertTo-Json' 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">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:2 : 2_x000D__x000A_</S><S S="Error">+ (test.ps1) | ConvertTo-Json_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>
Exit code:  3
>>> 
florentR2
Messages: 100
Registration: February 13, 2020 - 5:23 PM

April 28, 2020 - 12:13

However, it works well if I use

Code: Select all

run(r'powershell.exe ./test.ps1')
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

April 28, 2020 - 12:18 PM

Hello,

both commands work for me, however

, this one will not work: `run_powershell('test.ps1')`

`run_powershell` does not expect a file
Locked