如何将LastWriteTime添加到此脚本?

时间:2018-09-13 08:57:08

标签: powershell

$dir = "\\server\BackupBuddy" 
Get-ChildItem $dir -Recurse -Directory |
ForEach-Object{
[pscustomobject]@{
    Folder = $_.Name
    Count = @(Get-ChildItem -Path $_.fullname -File).Count
    }
} | Select-Object Folder,Count 

如果文件也经过至少2天的过滤,那就更好了。 谢谢,我是新来的。

1 个答案:

答案 0 :(得分:0)

只需将LastWriteTime属性添加到您的pscustomobjectSelect-Object

$dir = "\\server\BackupBuddy" 
Get-ChildItem $dir -Recurse -Directory |
ForEach-Object{
[pscustomobject]@{
    Folder = $_.Name
    Count = @(Get-ChildItem -Path $_.fullname -File).Count
    LastWriteTime = $_.LastWriteTime
    }
 } | Select-Object Folder,LastWriteTime,Count