2017-08-30 59 views
0

我正在尝试创建文件系统清单。gci和gci -recurve具有不同类型的输出

这个工作,它让我的每个条目

Get-ChildItem \\Server\Share\* | Select-Object @{n='Path';e={ (Get-Item $_.PSPath).FullName }}, PSIsContainer, @{n='Owner';e={ (Get-Acl $_).Owner}}, @{n='Accesstostring';e={ (Get-Acl $_).Accesstostring}} 

的奥尔和ACL,但使用-Recurse给我空的所有者和Accesstostring

Get-ChildItem \\Server\Share\ -Recurse | Select-Object @{n='Path';e={ (Get-Item $_.PSPath).FullName }}, PSIsContainer, @{n='Owner';e={ (Get-Acl $_).Owner}}, @{n='Accesstostring';e={ (Get-Acl $_).Accesstostring}} 

为什么gci正在发送的东西阿龙管道在不同? 我该如何解决这个问题? (我不想制作一个阵列,因为它不适合内存)

回答

2

它们是不同的,因为一个数组包含一个文件列表,但在递归它是一个目录对象数组和每个目录对象包含文件列表。下面的代码将做你想要的。请注意,如果路径包含空格,则路径需要用引号引起来。

Get-ChildItem \\Server\Share\ -Recurse | Select-Object @{n='Path';e={ $_.FullName }}, PSIsContainer, @{n='Owner';e={ (Get-Acl $_.FullName).Owner}}, @{n='Accesstostring';e={ (Get-Acl $_.FullName).Accesstostring}} 
+0

任何想法如何通过只调用一次Get-Acl来加快速度? –

相关问题