我更改了Windows 2008机器上的用户配额,之后有些用户报告说他们能够读取但不能写入映射的主文件夹。 如果我在服务器pipe理器中重新input主文件夹path并接受默认提示…
"The \\server\folder home folder already exists. Do you want this user to be granted full control on this folder?"
这个问题消失了
有没有办法与Powershell做同样的事情脚本将检查,看看用户是否有权限,如果不重新分配他们?
与文件夹所有者一起列出文件夹权限,以确定谁没有完整的权限? 第二个问题我花了几个小时,结果好坏参半。
以下脚本似乎没有列出具有不匹配权限的文件夹。
get-acl "D:\users\*" | select Path -Expand Access | where { $_.Identityreference -notcontains 'NT AUTHORITY\SYSTEM' -and $_.Identityreference -notcontains 'CREATOR OWNER' -and $_.Identityreference -notcontains 'BUILTIN\Administrators' -and $_.Identityreference -notcontains 'BUILTIN\Users' -and $_.Identityreference -notcontains 'BUILTIN\Account Operators' -and $_.Identityreference -notcontains 'BUILTIN\BUILTIN\Users'} | select @{Expression={$_.path};Label="Folder"}, @{Expression={$_.IdentityReference};Label="User"}, @{Expression={$_.AccessControlType};Label="Permissions"} | Format-Table -Wrap -AutoSize
由于您在AD中设置主文件夹,为什么不重新分配使用ADUC和variables?
假设您的文件夹被命名为您的用户名
您可以过滤视图以仅显示当前为其主文件夹设置值的用户。
select所有要更新的用户,然后转到这些用户的属性,然后selectProfile
选项卡。
在主文件夹的path中input这样的内容:
\\<servername>\Home Folders\%USERNAME%
然后打好。 它将循环并重置每个文件夹的权限,使用他们各自的用户名。
您将需要更改path以匹配path,但重要的部分是%USERNAME%
。
要检查文件夹或文件的所有权,可以使用GetOwner方法:
$acl = Get-Acl $dir.fullname $acl.GetOwner([System.Security.Principal.NTAccount])
并设置新的所有者:
$objUser = New-Object System.Security.Principal.NTAccount("YourDomain", "YourUser") $acl.SetOwner($objUser)
这可能有帮助。 我不得不修复我后来采用的共享文件夹configuration的权限。 使用powershell和subinacl.exe(因为远程更改所有者不常用)。 这也被用来做一些清理,所以这里有一些额外的代码来重新命名禁用或删除的用户帐户文件夹。 这是一个使用Quest cmdlet的旧脚本,现在可以用原生AD cmdletreplace它。
Add-PSSnapin quest* $dirlist = gci \\server\share | ? { $_.PSIsContainer } $subinacl = "C:\utils\subinacl.exe" foreach ($userdir in $dirlist) { #the foldername was a funny format (citrix 2008 profile with .2k8 suffix) $username = $userdir.name.Split('.')[0] $adaccount = Get-QADUser $username If (($adaccount.AccountIsDisabled -eq $TRUE) -or (!$adaccount)) { write-host "$username is not a current employee" #rename folder to _DEL_originalname $newname = "_DEL_$username" rename-item -path $userdir -newname $newname } Else { #get full path Write-Host "$userdir - changing permissions" $currentDir = $userdir.FullName # this way you don't duplicate the start folder #get ACL of folder $acl = Get-Acl $currentDir If ($acl.access -notcontains $username) { #variable to set new permissions for username of folder $permission = "domain\$username",”FullControl”,”ContainerInherit,ObjectInherit”,”None”,”Allow” $accessRule = new-object System.Security.AccessControl.FileSystemAccessRule $permission #actually set the permissions $acl.SetAccessRule($accessRule) Set-Acl $currentDir $acl #use subinacl to set owner at parent level and below $params1 = "/file $currentDir /setowner=domain\$username" $params2 = "/subdirectories $currentDir\*.* /setowner=domain\$username" $params3 = "/subdirectories $currentDir\* /grant=domain\$username" $params4 = "/subdirectories $currentDir\* /grant=domain\administrators=F" Invoke-Expression "$subinacl $params1" | out-null Invoke-Expression "$subinacl $params2" | out-null Invoke-Expression "$subinacl $params3" | out-null } } }