【发布时间】:2018-04-21 15:25:28
【问题描述】:
我在使用 powershell 创建主文件夹时遇到了一些问题,我创建了文件夹
New-Item -Path "C:\Homes\" -name $username -ItemType Directory
然后我复制 ACL 并禁用继承并添加新权限
$Rights = [System.Security.AccessControl.FileSystemRights]"FullControl"
$Inheritance = [System.Security.AccessControl.InheritanceFlags]::"ContainerInherit", "ObjectInherit"
$Propagation = [System.Security.AccessControl.PropagationFlags]::None
$AC =[System.Security.AccessControl.AccessControlType]::Allow
$NewACL = New-Object System.Security.AccessControl.FileSystemAccessRule ($username, $Rights, $Inheritance, $Propagation, $AC)
$ACL = Get-Acl -Path "C:\Homes\$username"
$ACL.SetAccessRuleProtection($True, $False)
$ACL.SetAccessRule($NewACL)
$NewACL = New-Object System.Security.AccessControl.FileSystemAccessRule ("SYSTEM", $Rights, $Inheritance, $Propagation, $AC)
$ACL.SetAccessRule($NewACL)
$NewACL = New-Object System.Security.AccessControl.FileSystemAccessRule ("Administrators", $Rights, $Inheritance, $Propagation, $AC)
$ACL.SetAccessRule($NewACL)
Set-Acl -Path "C:\Homes\$username" -AclObject $ACL
最后我将文件夹挂载为 H: 并将其设置为主目录
Set-ADUser -Identity $username -Replace @{HomeDirectory=$homeDir}
Set-ADUser -Identity $username -Replace @{HomeDrive=$homeDrive}
当我登录用户并尝试添加文件/文件夹时,我收到的权限被拒绝。 根文件夹 (C:\Homes) 已共享并已配置权限
【问题讨论】:
标签: windows powershell active-directory