enhl
Posts: 3
Joined: Tue Oct 31, 2023 4:48 am

Powershell script run as Admin Set-ExecutionPolicy Remote Signed

Hi team,

1) Place zip file in set location e.g. C:\Users\xxx\Downloads
2) I need to open Powershell as administrator, then these 2 commands in the directory
a) Unblock-File -Path <path-to-powershell-installation-script>
b) Set-ExecutionPolicy RemoteSigned and answer A
c) I place powershell (ps) script in same directory where the zip is and execute ps script i.e. .\<path-to-installation-script>
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: Powershell script run as Admin Set-ExecutionPolicy Remote Signed

Hello and welcome to our forums,

I'm afraid I do not quite understand your scenario here and what you're trying to achieve.

If possible, could you please give me some more details (with screenshots from your project)?

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
enhl
Posts: 3
Joined: Tue Oct 31, 2023 4:48 am

Re: Powershell script run as Admin Set-ExecutionPolicy Remote Signed

Hi Caitlin,

I am unable to attach screen capture to this post, when I add an attachment, it shows an error.

I was hoping that Advanced Installer could help me with either Option 1 or 2

Option 1:
Help create a MSI installer that would one click execute a powershell script that needs the contents of the zip folder for installation.

My current manual steps
1) Place zip file in set location e.g. C:\Users\xxx\Downloads
2) I need to open Powershell as administrator, then these 2 commands in the directory
a) Unblock-File -Path <path-to-powershell-installation-script>
b) Set-ExecutionPolicy RemoteSigned and answer A
c) I place powershell (ps) script in same directory where the zip is and execute ps script i.e. .\<path-to-installation-script>

MS installation would need to
1) Place zip file in set location e.g. C:\Users\xxx\Downloads
2) Execute Powershell script in administrator mode. Prior to powershell script execution I usually need these 2 commands
a) Unblock-File -Path <path-to-powershell-installation-script>
b) Set-ExecutionPolicy RemoteSigned and answer A -> for the above commands, does Advanced Installer have ways for these
c) powershell script needs to execute in same directory as the zip

Option 2:
I created a .exe based of the zip and the powershell script. It is currently one click execution, just needs the user to place it in any directory and run in administrator mode.

How do I create a MSI off the .exe and the MSI will run the .exe in administrator mode, because the powershell script within the .exe needs it.
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: Powershell script run as Admin Set-ExecutionPolicy Remote Signed

Hello,

Thank you for your follwup on this and for sharing the details with me.

Now I understand what you are trying to achieve.

So, in order to achieve that within Advanced Installer, we can proceed as it follows:

- create a new project

- in the "Files and Folders" page, select the location where you want the ZIP archive to be extracted and add the ZIP there

Path to folders in the Files and Folders page

- you can then go to "Custom Actions" page and add an "Inline PowerShell script" custom action after the "Add resources" action group

- for this custom action, set the "When the system is being modified (deferred)" and "Run under the LocalSystem account with full privileges (no impersonation)" options

- input the custom action code

Note: we would need here to either get the path of the ZIP or use Powershell's Set-Location cmdlet to set the location to the folder where the ZIP resides.

- build&run the setup

Hope this helps!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
enhl
Posts: 3
Joined: Tue Oct 31, 2023 4:48 am

Re: Powershell script run as Admin Set-ExecutionPolicy Remote Signed

Hi Caitlin,
I followed the steps but it doesn't seem the powershell script gets executed. Would you have a step by step video or tutorial that I could follow.
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: Powershell script run as Admin Set-ExecutionPolicy Remote Signed

Hello,

I'm afraid there isn't any step-by-step guide for this.

If possible, could you please forward me a copy of your AIP file and a download link for your setup by email at support at advancedinstaller dot com so I can further assist you here?

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”