我试图执行按位或(|)操作将多个枚举应用于.NET程序集使用的PowerShell中的变量.但是,当单管道字符执行此操作时,我收到Expressions are only allowed as the first element of a pipeline错误.如何在PowerShell中分配多个枚举?
$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 | [System.Security.AccessControl.InheritanceFlags]::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);
Run Code Online (Sandbox Code Playgroud)
Mic*_*lli 11
使用 -bor
[System.Security.AccessControl.InheritanceFlags]::ContainerInherit -bor [System.Security.AccessControl.InheritanceFlags]::ObjectInherit
ContainerInherit, ObjectInherit
Run Code Online (Sandbox Code Playgroud)