To accomplish this we have a custom action powershell script. It's added as "Attached script" we have on disk and contents of that script is:
Code: Select all
function Append-SecurityGroup {
param (
[string]$fileOrFolder
)
if(!(Test-Path -Path $fileOrFolder)) {
New-Item -ItemType Directory -Force -Path $fileOrFolder | Out-Null
}
# SIDs
$admins = New-Object System.Security.Principal.SecurityIdentifier('S-1-5-32-544')
$users = New-Object System.Security.Principal.SecurityIdentifier('S-1-5-32-545')
# Permissions on temp folder
$inheritanceFlag = [System.Security.AccessControl.InheritanceFlags]::ContainerInherit -bor [System.Security.AccessControl.InheritanceFlags]::ObjectInherit
$propagationFlag = [System.Security.AccessControl.PropagationFlags]::None
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule($users, "ReadAndExecute", $inheritanceFlag, $propagationFlag, "Allow")
$accessRuleAdmin = New-Object System.Security.AccessControl.FileSystemAccessRule($admins, "FullControl", $inheritanceFlag, $propagationFlag, "Allow")
$backupAcl = Get-Acl -path "$($fileOrFolder)"
$backupAcl.SetAccessRule($accessRule)
Set-Acl -Path "$($fileOrFolder)" -AclObject $backupAcl
}
Append-SecurityGroup "MyCustomFolder"
- We used to use $env:TEMP\MyCustomFolder but that ended up creating the folder under AppData\Local\Temp\MyCustomFolder when running it through the installer. When running the same powershell script under powershell shell it created it under AppData\Local\Temp\<sessionID>\MyCustomFolder (same as the folder the installer extracts files to).
So off the bat we seem to have a difference. This I fixed by telling advanced installer to run the script in the temp folder and just provide the folder name. - The problem that still exists is that the permissions are no longer set. The folder is created, but no permissions are applied. This is only the case when running it as a custom action. If I run the same script in a powershell console it works, with permissions being set correctly.
The installer works on Windows 2019 Server, but not in 2022 or 2025. I would like to get to the bottom of this and figure out how to fix it.
Version of advanced installer used: v22.3
FOLLOW US