How do I perform a bitwise or (|) for enumerations in PowerShell?

PowerShell will provide automatic conversion from strings, so you could also do this:

$everyone = New-Object System.Security.Principal.SecurityIdentifier([System.Security.Principal.WellKnownSidType]::WorldSid, $null);
$fsr = [System.Security.AccessControl.FileSystemRights]::Read;
$if = [System.Security.AccessControl.InheritanceFlags]"ContainerInherit,ObjectInherit"
$pf = [System.Security.AccessControl.PropagationFlags]::None;
$act = [System.Security.AccessControl.AccessControlType]::Allow;
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule($everyone, $fsr, $if, $pf, $act);

In fact if you wanted it to be significantly less to type (good for quick command line stuff when you don't care about clarity for reading later) you could do it like this:

$everyone = New-Object System.Security.Principal.SecurityIdentifier([System.Security.Principal.WellKnownSidType]::WorldSid, $null);
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $everyone, "Read", "ContainerInherit,ObjectInherit", "None", "Allow"

Use the -bor bitwise operator, e.g.:

([System.Security.AccessControl.InheritanceFlags]::ContainerInherit -bor
 [System.Security.AccessControl.InheritanceFlags]::ObjectInherit)

ContainerInherit, ObjectInherit

Tags:

Powershell