Search code examples
powershellnsis

Using powershell to silently install software when verification is required


It's a simple script, I just need to install several software on a couple of machines.

C:\Users\user\Downloads\executable.exe /S /D=C:\Program Files\Executable\
C:\Users\user\Downloads\executable1.exe /S /D=C:\Program Files\Executable1\
C:\Users\user\Downloads\executable2.exe /S /D=C:\Program Files\Executable2\

However, our admins require you to select a reason from a dropdown and enter your password every time you need admin access to do something.

Is there a workaround for this?

Edit: as is now, it looks like it's installing, but it fails. If I take the silent off, the pop up comes up and after entering the proper values, it'll proceed with the installation.


Solution

  • As for this...

    "our admins require you to select a reason from a dropdown and enter your password every time you need admin access to do something.
    
    Is there a workaround for this?"
    

    So, they are monitoring install events using native Windows polices or a 3rdP tool to prevent unauthorized installs???

    Soooooo.... you are asking the forum members to help you with code to circumvent/violates your organization's security / risk management policy??? In most orgs, violating security / risk policies is an RPE (resume producing event). Should you not be talking to your orgs policy makers first?

    Anyways, if you are authorized to do this install work, the approach would be no different than trying to push data to a form. You trap the form Window, enumerate the input boxes to be able to know what they are and take needed actions. PoSH, out of box, is really not designed for that sort of thing. You need a tool that can programmatically deal with GUI and potentially a GUI which does not have a known interface to automate against.

    Look to tools like WASP, it's a bit dated, but may work for you.

    WASP is a PowerShell snapin for Windows Automation tasks like selecting windows and controls and sending mouse and keyboard events. We have automation cmdlets like Select-Window, Select-Control, Send-Keys, Send-Click, Get-WindowPosition, Set-WindowPosition, Set-WindowActive, Remove-Window ... etc.

    http://wasp.codeplex.com

    Or AutoIT

    https://www.autoitscript.com/site/autoit

    BTW, if you are trying to do this in the context of a user on a remote host, PoSH will not let you do this, it is restricted by Windows Security Principal boundaries. Tools like PSExec, can help here AutoIt.