When I run the code below, I see that the parent folder has the right security, but the sub-folders have as security everyone and system (full control) and inheritance is off.
Make I an mistake in the code
$objPath = "${env:ProgramFiles(x86)}\Guentner"
Write-Log -Message "Set-Acl On folder $objPath" -Severity 1 -Source $deployAppScriptFriendlyName
#removes all inheritance for the folder
$acl = Get-Acl $objPath
$acl.SetAccessRuleProtection($true, $true)
$acl | Set-Acl $objPath
$objuser = New-Object System.Security.Principal.ntaccount("INGEBOUWD\Gebruikers")
$colRights = [System.Security.AccessControl.FileSystemRights]"CreateFiles, Appenddata, ReadAndExecute"
$inheritanceflag = [System.Security.AccessControl.InheritanceFlags]::None
$propagationflag = [System.Security.AccessControl.PropagationFlags]::None
$objtype = [System.Security.AccessControl.AccessControlType]::Allow
$objace = New-Object System.Security.AccessControl.FileSystemAccessRule($objuser, $colRights, $inheritanceflag, $propagationflag, $objtype)
$objacl = get-acl $objPath
$objacl.RemoveAccessRuleall($objace)
set-acl $objPath $objacl
$objuser = New-Object System.Security.Principal.ntaccount("D40\APPL_Guentner GPC")
$colRights = [System.Security.AccessControl.FileSystemRights]"FullControl"
$inheritanceflag = @([System.Security.AccessControl.InheritanceFlags]::ContainerInherit, [System.Security.AccessControl.InheritanceFlags]::ObjectInherit)
$propagationflag = [System.Security.AccessControl.PropagationFlags]::None
$objtype = [System.Security.AccessControl.AccessControlType]::Allow
$objace = New-Object System.Security.AccessControl.FileSystemAccessRule($objuser, $colRights, $inheritanceflag, $propagationflag, $objtype)