530530 # Get a copy of the rule (we don't want to touch the original object)
531531 Write-Debug " $ ( $MyInvocation.MyCommand ) : No conversion necessary"
532532 $Rule = $Rule.Copy ()
533- $IsRuleInherited = [bool ] ($Rule.AceFlags -band [System.Security.AccessControl.AceFlags ]::Inherited)
533+ $IsRuleInherited = [bool ] ([ int ] $Rule.AceFlags -band [System.Security.AccessControl.AceFlags ]::Inherited.value__ )
534534 break
535535 }
536536
618618 ($_ -eq " Microsoft.Management.Infrastructure.CimInstance" -and
619619 ($Rule.CimClass.CimClassName -eq " Win32_ACE" ) -or ($Rule.CimClass.CimClassName -eq " __ACE" )) } {
620620
621- $IsRuleInherited = [bool ] ($Rule.AceFlags -band [System.Security.AccessControl.AceFlags ]::Inherited)
621+ $IsRuleInherited = [bool ] ([ int ] $Rule.AceFlags -band [System.Security.AccessControl.AceFlags ]::Inherited.value__ )
622622
623623 # Long and scary looking condition, but it just means do the
624624 # following if it's a WMI object of the Win32_ACE class
643643
644644 if ($Rule.AceType -eq [System.Security.AccessControl.AceQualifier ]::SystemAudit) {
645645 # Not an access entry, but an audit entry
646- $Params.AuditSuccess = [bool ] ($Rule.AceFlags -band [System.Security.AccessControl.AceFlags ]::SuccessfulAccess)
647- $Params.AuditFailure = [bool ] ($Rule.AceFlags -band [System.Security.AccessControl.AceFlags ]::FailedAccess)
646+ $Params.AuditSuccess = [bool ] ([ int ] $Rule.AceFlags -band [System.Security.AccessControl.AceFlags ]::SuccessfulAccess.value__ )
647+ $Params.AuditFailure = [bool ] ([ int ] $Rule.AceFlags -band [System.Security.AccessControl.AceFlags ]::FailedAccess.value__ )
648648 }
649649
650650 # Make the rule:
@@ -666,14 +666,14 @@ etc.
666666 # it's usually to add or remove an ACE. In either of those
667667 # scenarios, you don't want the resulting ACE to still be
668668 # inherited, so remove that flag if it's present
669- if ($Rule.AceFlags -band [System.Security.AccessControl.AceFlags ]::Inherited) {
670- $Rule.AceFlags = $Rule.AceFlags -bxor [System.Security.AccessControl.AceFlags ]::Inherited
669+ if ([ int ] $Rule.AceFlags -band [System.Security.AccessControl.AceFlags ]::Inherited.value__ ) {
670+ $Rule.AceFlags = [ int ] $Rule.AceFlags -bxor [System.Security.AccessControl.AceFlags ]::Inherited.value__
671671 }
672672 }
673673 else {
674- if ($IsRuleInherited -and (-not ($Rule.AceFlags -band [System.Security.AccessControl.AceFlags ]::Inherited))) {
674+ if ($IsRuleInherited -and (-not ([ int ] $Rule.AceFlags -band [System.Security.AccessControl.AceFlags ]::Inherited.value__ ))) {
675675 # If the original rule was inherited, but the converted one isn't, fix it!
676- $Rule.AceFlags = $Rule.AceFlags -bxor [System.Security.AccessControl.AceFlags ]::Inherited
676+ $Rule.AceFlags = [ int ] $Rule.AceFlags -bxor [System.Security.AccessControl.AceFlags ]::Inherited.value__
677677 }
678678 }
679679
0 commit comments