[英]Using Powershell To Check Home Folder Permissions For All AD users
How can I check home folder permissions for all AD users via Powershell?如何通过 Powershell 检查所有 AD 用户的主文件夹权限?
Here's my script so far:到目前为止,这是我的脚本:
$MyUser = Get-ADUser -filter 'name -like "*"'
foreach ($User in $MyUser)
{
(Get-ACL -path \\NameOfMyServer\home\$MyUser).access | ft
IdentityRerference,FileSystemRights,IsInherited -Auto
}
I get a long, long error message (one message for each user) that says, "ObjectNotFound (:) [Get-ACL] ItemNotFoundException Get-ACL_PathNotFound_Exception,Microsoft,Powershell.Commands.Get-ACLCommand."我收到一条长长的错误消息(每个用户一条消息),上面写着“ObjectNotFound (:) [Get-ACL] ItemNotFoundException Get-ACL_PathNotFound_Exception,Microsoft,Powershell.Commands.Get-ACLCommand。”
I can get it to work, but only when I run it for one user at a time this:我可以让它工作,但只有当我一次为一个用户运行它时:
(Get-ACL -path \\NameOfMyServer\home\barry.scott).access | ft
IdentityRerference,FileSystemRights,IsInherited -Auto
I've also tried it like this:我也试过这样:
$MyUser = Get-ADUser -filter 'name -like "$_.GivenName.$_.Surname*"'
foreach ($User in $MyUser)
{
(Get-ACL -path \\NameOfMyServer\home\$MyUser).access | ft
IdentityRerference,FileSystemRights,IsInherited -Auto
}
In this form I get no output and no errors.在这种形式中,我没有得到 output 并且没有错误。
This is for Server 2012. Any thoughts?这是针对 Server 2012 的。有什么想法吗?
I hope this makes sense - thank you!我希望这是有道理的-谢谢!
You currently have你目前有
(Get-ACL -path \\NameOfMyServer\home\$MyUser).access
You probably want你可能想要
(Get-ACL -path \\NameOfMyServer\home\$User.SamAccountName).access
Complete Example完整示例
$MyUser = Get-ADUser -filter 'name -like "*"'
foreach ($User in $MyUser)
{
(Get-ACL -path \\NameOfMyServer\home\$($User.SamAccountName)).access | ft IdentityReference,FileSystemRights,IsInherited -Auto
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.