Get-ChildItem两次返回相同的文件夹

时间:2014-01-29 15:48:38

标签: powershell get return directory

有人可以告诉我为什么get-childitem会两次返回同一个文件夹吗?

代码

$StartTime = (get-date)

new-item "D:\Shares\Vorsorge\000_Musterkunde\Folder" -type directory

Get-ChildItem "D:\Shares\Vorsorge\000_Musterkunde" -Recurse | where-object {$_.CreationTime -gt $starttime}

输出

Verzeichnis: D:\Shares\Vorsorge\000_Musterkunde


Mode                LastWriteTime     Length Name                                                                                                                                                                                              
----                -------------     ------ ----                                                                                                                                                                                              
d----        29.01.2014     16:45            Folder                                                                                                                                                                                            
d----        29.01.2014     16:45            Folder    

1 个答案:

答案 0 :(得分:3)

Get-Childitem仅返回1.另一个由New-Item输出。试试这个,看看你是否只得到一个:

$StartTime = (get-date)

new-item "D:\Shares\Vorsorge\000_Musterkunde\Folder" -type directory > $null

Get-ChildItem "D:\Shares\Vorsorge\000_Musterkunde" -Recurse | where-object {$_.CreationTime -gt $starttime}