Page 1 of 1

[ISO Mount] - privilege elevation required

Published: January 30, 2023 - 11:33 AM
by Mathis
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?

Re: [ISO Mounting] - privilege elevation required

Published: January 30, 2023 - 5:08 PM
by sfonteneau
Hello,

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

Simon

Re: [ISO Mounting] - privilege elevation required

Published: January 30, 2023 - 5:29 PM
by Mathis
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

Re: [ISO Mounting] - privilege elevation required

Published: January 30, 2023 - 8:33 PM
by vcardon
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.