[ISO Mount] - privilege elevation required

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
Mathis
Messages: 8
Registration: Nov 23, 2022 - 08:53

January 30, 2023 - 11:33

WAPT version: 2.2.3.12481
Enterprise Edition
Server OS: Windows Server 2019
Operating system of the machine: Windows 10

Hello, I have been trying for some time to create a package to mount an ISO under Windows which is located on a network drive using PowerShell command line, the main problem being the privilege elevation request.
I tried something like this:

Code: Select all

def run_powershell(command):
        subprocess.run(['powershell',command])
run_powershell('Start-Process PowerShell.exe -Verb RunAs -ArgumentList "-NoProfile -NonInteractive C:\temp\ScriptCred.ps1" -WindowStyle Hidden')
In the script, I use a credential to provide the identification details in order to mount the iso with administrator rights, however the process does not happen completely without interaction since a Windows dialog box appears in order to continue and authorize the rest.

Is it therefore possible to increase ISO in a completely automatic way?
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

January 30, 2023 - 5:08 PM

Hello,

to help you better, could you please give us the general context of what you want to do?

Simon
Mathis
Messages: 8
Registration: Nov 23, 2022 - 08:53

January 30, 2023 - 5:29 PM

Hello, I finally succeeded by trying a different approach.
My goal was to mount an ISO image that was located on a network drive; my script worked, only a dialog box asking to authorize the continuation of the process was missing because it did not allow to result in a completely interaction-free package.

So I tried a simple run with Powershell.exe as the first parameter, followed by the path to my script, like this:

Code: Select all

run("PowerShell.exe script.ps1")
If it helps, here's my PowerShell script to help you understand a little better:

Code: Select all

$username = "[username]"
$password = "[password]"
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential $username, $securePassword
$isoImg = "‪\\[Serveur]\[CheminDuFichier.iso]"
$driveLetter = "J:"


$diskImg = Mount-DiskImage -ImagePath $isoImg -NoDriveLetter 

$volInfo = $diskImg | Get-Volume

mountvol $driveLetter $volInfo.UniqueId
User avatar
vcardon
WAPT Expert
Messages: 278
Registration: Oct 06, 2017 - 10:55 p.m.
Location: Nantes, France

January 30, 2023 - 8:33 PM

Hello Mathis

I'm very glad that your process worked well for you.

However, we strongly advise the WAPT community against using network drives in their WAPT scripts. WAPT's Nginx web service is better suited for serving ISO files
  • It's simpler.
  • It works automatically with secondary repositories.
  • You can format machines that are not on your network but that can see the WAPT server.
Vincent CARDON
Tranquil IT
Locked