【发布时间】:2015-06-19 09:01:59
【问题描述】:
我查看了其他帖子,甚至关注了那些我无法让它发挥作用的帖子。
我正在尝试从驱动器中提取所有 ACL 信息,但不包括 Windows 文件夹。
这是我正在使用的代码,但它总是试图包含该文件夹。谁能告诉我为什么这不起作用?
我也试过Where-Object。
$containers = Get-ChildItem -Path $Path -Recurse -Exclude $exclude |
? {$_.FullName -notmatch '\\windows\\?'}
主代码:
function Get-PathPermissions {
param ( [Parameter(Mandatory=$true)] [System.String]${Path} )
begin {
$root = Get-Item $Path
($root | Get-Acl).Access |
Add-Member -MemberType NoteProperty -Name "Path" -Value $($root.fullname).ToString() -PassThru
}
process {
$exclude = @('C:\Windows\*')
$containers = Get-ChildItem -Path $Path -Recurse -Exclude $exclude |
? {$_.psIscontainer -eq $true}
if ($containers -eq $null) {break}
foreach ($container in $containers)
{
(Get-Acl $container.FullName).Access |
? { $_.IsInherited -eq $false } |
Add-Member -MemberType NoteProperty -Name "Path" -Value $($container.fullname).ToString() -PassThru
}
}
}
Get-PathPermissions $args[0]
【问题讨论】:
-
尝试 Get-ChildItem 'C:*' -Exclude 'Windows'
-
谢谢,但这似乎也不起作用。我输入的命令行是 .\NTFSPermissions.ps1 "C:\" |导出 Csv C:\Permissions\output.csv -NoTypeInformation。还尝试了排除“Windows”
-
尝试使用 \NTFSPermissions.ps1 "C:*" | 调用脚本Export-Csv C:\Permissions\output.csv -NoTypeInformation
-
是的,这正是我所做的 :) 仍然没有运气。事实上,它输出一个小文件,其路径返回为 System.Object[]