[SOLVED] Problem executing a PowerShell script using the PowerShell run function

Questions about WAPT Server / Requests and help related to the WAPT server
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
Albin
Messages: 17
Registration: Apr 26, 2022 - 2:55 p.m.

May 3, 2022 - 4:04 PM

Hello,

Yes, that is indeed the name of my package.

I ran the command: `wapt-get session-setup Printer -f` and I got this result

: `Using config file: C:\Program Files (x86)\wapt\wapt-get.ini
Configuring Printer ...
Done`.

It indicates the package configuration is complete, but the change is not being applied to my machine.
Regards,

Albin,
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

May 3, 2022 - 4:12 PM

In a cmd (in NO (administrator) you can launch:

Code: Select all

powershell.exe -executionpolicy bypass c:\test.ps1
To check if the problem isn't with run_powershell_from_file
Albin
Messages: 17
Registration: Apr 26, 2022 - 2:55 p.m.

May 3, 2022 - 4:18 PM

I ran the command: powershell.exe -executionpolicy bypass c:\testwapt.ps1 and the change was successfully applied to my machine.

Regards,

Albin
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

May 3, 2022 - 4:38 PM

To run the test again:
Can you change the package code to:

Code: Select all

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

def install():
    filecopyto('testwapt.ps1',r'c:\testwapt.ps1')

def session_setup() :
    print('configure imprimante')
    print(run_powershell_from_file(r"c:\testwapt.ps1",output_format="text"))
restart the installation of the wapt package

And finally, restart the command:

Code: Select all

wapt-get session-setup Imprimante -f
With the return


We just did an internal test here and it works for us
Albin
Messages: 17
Registration: Apr 26, 2022 - 2:55 p.m.

May 4, 2022 - 12:18

Hello,

I ran the script in question.
After the script ran, I executed the command `wapt-get session-setup Printer -f` as requested.
Unfortunately, I had to restart my computer for it to work. Is this normal?
Is it possible to run the script without having to execute the command mentioned above (`wapt-get session-setup Printer -f`)?


Thank you in advance for your reply,

Best regards,

Albin
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

May 4, 2022 - 1:38 PM

The session-setup runs automatically when a session is opened.

It also runs automatically in sessions opened after each installation launched via the console.

However, in debug mode (PyScripter and package development), the session-setup must be run manually.

Note that the session-setup runs only once per package version for each session!
Albin
Messages: 17
Registration: Apr 26, 2022 - 2:55 p.m.

May 4, 2022 - 2:51 PM

Thank you so much for your help
Locked