String cmdlet中的函数名
我尝试在set-acl cmdlet中使用我的函数,但它确实工作正常,我的函数被识别为一个简单的“字符串”String cmdlet中的函数名,string,function,powershell,cmdlet,String,Function,Powershell,Cmdlet,我尝试在set-acl cmdlet中使用我的函数,但它确实工作正常,我的函数被识别为一个简单的“字符串” 它被识别为字符串,因为您将其作为字符串编写。引号(“or”)中的所有内容都是字符串 如果函数返回字符串值,则可以如下使用: $acl = Get-Acl C:\MSI -Verbose $acl.SetAccessRuleProtection($True, $False) $rule = New-Object System.Security.AccessControl.FileSyste
它被识别为字符串,因为您将其作为字符串编写。引号(“or”)中的所有内容都是字符串 如果函数返回字符串值,则可以如下使用:
$acl = Get-Acl C:\MSI -Verbose
$acl.SetAccessRuleProtection($True, $False)
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule ("Get-GroupName -SID 'S-1-1-0'","FullControl", "ContainerInherit, ObjectInherit", "None", "Allow") -Verbose
$acl.AddAccessRule($rule)
$rule = New-ObjectSystem.Security.AccessControl.FileSystemAccessRule("Get-GroupName -SID 'S-1-5-32-544'","Readandexecute", "ContainerInherit, ObjectInherit", "None", "Allow") -Verbose
$acl.AddAccessRule($rule)
Set-Acl C:\MSI $acl
$acl = Get-Acl C:\MSI -Verbose
$acl.SetAccessRuleProtection($True, $False)
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule ((Get-GroupName -SID 'S-1-1-0'),"FullControl", "ContainerInherit, ObjectInherit", "None", "Allow") -Verbose
$acl.AddAccessRule($rule)
$rule = New-ObjectSystem.Security.AccessControl.FileSystemAccessRule((Get-GroupName -SID 'S-1-5-32-544'),"Readandexecute", "ContainerInherit, ObjectInherit", "None", "Allow") -Verbose
$acl.AddAccessRule($rule)
Set-Acl C:\MSI $acl