How To Configure a PowerShell Custom Action that Grants Permissions to Administrators and No Other Users

How To Configure a PowerShell Custom Action that Grants Permissions to Administrators and No Other Users

Summary:

This article discusses how to configure a PowerShell custom action that grants permissions to Administrators and no other users.

Solution:

1. Configure a PowerShell custom action that calls the following PowerShell cmdlet:

 

Invoke-Expression -Command:"icacls 'C:\Program Files\Permission' /inheritance:r /grant Administrators:F"

 

2. Set In-Script Execution to Immediate Execution.

3. Sequence the custom action in the Install Exec Sequence After InstallFinalize with the following Install Exec Condition:

 

NOT REMOVE~="ALL"

 

See the attached sample project for more details. In this case, the PowerShell custom action sets the permissions on INSTALLDIR.

Additional Information:

Click here for the official Microsoft documentation, an introduction to PowerShell.

Click here for the official Microsoft documentation about the Invoke-Expression PowerShell cmdlet.

Click here for the official Microsoft documentation about the icacls Windows command called by the PowerShell custom action.

Was this article helpful? Yes No
No ratings
Version history
Revision #:
4 of 4
Last update:
‎Jun 11, 2021 05:04 PM
Updated by:
 
Contributors