Hi Albin,
since you're defining variables, it's not possible to run them individually; you have to maintain the context.
In your last post, you have a "-WmiObject" command without the "Get"... It's normal that it crashes, probably an accidental copy-paste.
By the way, are you running `run_powershell_from_file` using `def session_setup()` or `def install()`? If it's using `def install()`, it's normal that it doesn't work; your code is context-dependent.
Regards,
Denis.
PS: Please put your code snippets and shell output in code blocks; it's much more readable.
[SOLVED] Problem executing a PowerShell script using the PowerShell run function
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
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
- dcardon
- WAPT Expert
- Messages: 1932
- Registration: June 18, 2014 - 09:58
- Location: Saint Sébastien sur Loire
- Contact :
Denis Cardon - Tranquil IT
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
I re-ran my script using the run_powershell_from_file command
here is the code
I'm getting errors in the console when I deploy to a machine.
Here are the errors:
Sincerely,
Albin
here is the code
Code: Select all
# -*- coding: utf-8 -*-
from setuphelpers import *
# Usable WAPT package functions: install(), uninstall(), session_setup(), audit(), update_package()
# Declaring global variables - Warnings: 1) WAPT context is only available in package functions; 2) Global variables are not persistent between calls
def session_setup() :
run_powershell_from_file("testwapt.ps1")Here are the errors:
Code: Select all
Traceback (most recent call last):
File "C:\Program Files (x86)\wapt\common.py", line 3938, in install_wapt
exitstatus = setup.install()
AttributeError: module '__waptsetup_ttmou6pwdf__' has no attribute 'install'
AttributeError: module '__waptsetup_ttmou6pwdf__' has no attribute 'install'
Albin
- sfonteneau
- WAPT Expert
- Messages: 2318
- Registered: July 10, 2014 - 11:52 PM
- Contact :
Code: Select all
# -*- coding: utf-8 -*-
from setuphelpers import *
def install():
filecopyto('testwapt.ps1',r'c:\testwapt.ps1')
def session_setup() :
run_powershell_from_file(r"c:\testwapt.ps1")
Good morning,
We tested your script, we don't have any errors in the Wapt console, but it still doesn't work
The copy of the testwapt.ps1 file is successful on the machine, but the script does not execute.
Sincerely,
Albin
We tested your script, we don't have any errors in the Wapt console, but it still doesn't work
Code: Select all
# -*- coding: utf-8 -*-
from setuphelpers import *
def install():
filecopyto('testwapt.ps1',r'c:\testwapt.ps1')
def session_setup() :
run_powershell_from_file(r"c:\testwapt.ps1")
Sincerely,
Albin
- sfonteneau
- WAPT Expert
- Messages: 2318
- Registered: July 10, 2014 - 11:52 PM
- Contact :
On the machine where the package was launched, you can do the following:
To see what that says
Code: Select all
wapt-get session-setup nom_de_votre_paquet -fHello again,
I ran the command and I got this message
: Using config file: C:\Program Files (x86)\wapt\wapt-get.ini
Configuring testwapt.ps1 ...
2022-05-02 12:00:05,183 CRITICAL Exception: Package testwapt.ps1 is not installed
. Regards,
Albin
I ran the command and I got this message
: Using config file: C:\Program Files (x86)\wapt\wapt-get.ini
Configuring testwapt.ps1 ...
2022-05-02 12:00:05,183 CRITICAL Exception: Package testwapt.ps1 is not installed
. Regards,
Albin
- sfonteneau
- WAPT Expert
- Messages: 2318
- Registered: July 10, 2014 - 11:52 PM
- Contact :
Not the script, but the name of your package (package field in your package's control file)
I ran the command again with the package name.
Here's the message I got:
Using config file: C:\Program Files (x86)\wapt\wapt-get.ini
Configuring Printer_0-wapt ...
2022-05-02 16:17:16,250 CRITICAL Exception: Package Printer_0-wapt is not installed.
Regards,
Albin
Here's the message I got:
Using config file: C:\Program Files (x86)\wapt\wapt-get.ini
Configuring Printer_0-wapt ...
2022-05-02 16:17:16,250 CRITICAL Exception: Package Printer_0-wapt is not installed.
Regards,
Albin
- sfonteneau
- WAPT Expert
- Messages: 2318
- Registered: July 10, 2014 - 11:52 PM
- Contact :
You specified the folder in waptdev and not the package name
So, judging by the folder name, I assume your package name is "Printer"
SO:
So, judging by the folder name, I assume your package name is "Printer"
SO:
Code: Select all
wapt-get session-setup Imprimante -f