/build/static/layout/Breadcrumb_cap_w.png

How To Perform A PowerShell Custom Action In Restricted , RemoteSigned in Window 7 Environment

Hello,

I am trying to share with you, a short tutorial to use PowerShell Custom Action. Please, let me know if there are some mistakes or misunderstanding.

Pre requirement :

  • PowerShell v1 or more (in my case i have v2)
  • InstallShield v2012 or with powershell module (in my case i have v2012)
  • Run MSI file as Admin user

To check the powershell version :

 

$PSVersionTable  

 

My custom firt action is write in ps1, remove registry value on installation

 

Remove-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Citrix\PNAgent -Name ServerURL -ErrorAction SilentlyContinue

 

and remove files and folders in the folder C:\Windonws\Logs\CBS during uninstallation.

 
Remove-Item "C:\Windows\Logs\CBS\" -Force -Recurse  -ErrorAction SilentlyContinue  
 

 

1)First set a System Search to check PowerShell is installed.

Signature

Root

Key

Name

Type

Windows_PowerShell_sin

2

SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine

PowerShellVersion

2

 

2)Next select the Policy execution for the Custom Action

Have to set the required property .

IS_PS_EXECUTIONPOLICY= Unrestricted|RemoteSigned|AllSigned

I choose Unrestricted because I have not signed my script.

 

Property

Value

IS_PS_EXECUTIONPOLICY

Unrestricted

 

3)After Add the PowerShell Custon Action

Action

Type

Source

Target

Extended

sample_custom_action_ps1

1

ISPSWRAP.DLL

PS1

 

 

4) In the Binary table add the script file

 

Name

Data

ISBuildSourcePath

ISPSWRAP.DLL

[Binary Data]

<ISProductFolder>\redist\language   independent\i386\PowerShellWrap.dll

5) Eventually put the custom action in the  sequence between the custom  ISPowerShellStartup  and  ISPowerShellCleanup  with the Condition :

POWERSHELLVERSION<>" " AND REMOVE="ALL" 

6) At the end compile and run it !

For more informations, looking for PowerShell in the InstallShield Help Library.


Comments

  • the above method, will work fine when using them in a ISM however, when adding the custom actions in a MST , there is no way to add them. Have you by any chance fumbled on a method which successfully does so. - talonsprem87 7 years ago
This post is locked

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ