我正在尝试执行按位或 (|) 操作,以将多个枚举应用于 .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);
Use the -bor
按位运算符 https://learn.microsoft.com/ro-ro/powershell/module/microsoft.powershell.core/about/about_arithmetic_operators#bitwise-operators, e.g.:
([System.Security.AccessControl.InheritanceFlags]::ContainerInherit -bor
[System.Security.AccessControl.InheritanceFlags]::ObjectInherit)
ContainerInherit, ObjectInherit
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)