【发布时间】:2014-07-02 21:02:22
【问题描述】:
我想报告用户对文件夹对象(不是文件)的权限。我正在尝试使用 get-acl powershell cmdlet 来完成此操作,但是我遇到了一个问题,我注意到我的代码没有正确获得所有权限。在检查用户权限并希望在用户权限可能会更改一个文件夹时获得例外情况时,我也会将其降低一级。
if ($ComputerName -eq '.'){
$Path = $Folder
}
else {
$Path = "\\$ComputerName\$Folder"
}ls
if ($OutputFile){
gci c:\|%{if($_.PSIsContainer){GCI $_.FullName|get-acl};$_|get-acl}| Select-Object @{Name="Path";Expression={$_.PSPath.Substring($_.PSPath.IndexOf(":")+2) }},@{Name="Type";Expression={$_.GetType()}},Owner -ExpandProperty Access | sort PSParentPath|Export-CSV $OutputFile -NoType
}
else{
gci c:\|%{if($_.PSIsContainer){GCI $_.FullName|get-acl};$_|get-acl}| Select-Object @{Name="Path";Expression={$_.PSPath.Substring($_.PSPath.IndexOf(":")+2) }},@{Name="Type";Expression={$_.GetType()}},Owner -ExpandProperty Access | sort PSParentPath|FT -Auto
}
随机文件夹报告数字,而不是给我 FileSystemRights。我的代码有问题吗?
【问题讨论】:
标签: powershell scripting ntfs