2016-04-25 71 views
1
Get-Childitem -path \\lettertext\BIZ -Recurse -Include *.txt | 
ForEach-Object { 
    $Parts = $_.fullname.split('\')[4..7] 
    [PSCustomObject]@{ 
     Customer = $Parts[0] 
     ClientGroup = $Parts[1] 
     Client = $Parts[2] 
     ClientDivision = $Parts[3] 
     FileName = $_.FullName | Split-Path -Leaf 


    } 
} | Export-Csv c:\Letters\BIZ.csv -NoTypeInformation 

上面的代码给我的文本文件在不同的文件夹,但我也想补充的最后修改日期和时间..谢谢我想上次修改的日期和时间添加到此PowerShell脚本

+0

可以公开属性/什么获取-ChildItem以“get-childitem返回方法|获取member' –

回答

1

这将做到这一点:

Get-Childitem -path \\lettertext\BIZ -Recurse -Include *.txt | 
ForEach-Object { 
    $Parts = $_.fullname.split('\')[4..7] 
    [PSCustomObject]@{ 
     Customer = $Parts[0] 
     ClientGroup = $Parts[1] 
     Client = $Parts[2] 
     ClientDivision = $Parts[3] 
     FileName = $_.FullName | Split-Path -Leaf 
     LastModifiedDate= $_.LastWriteTime 
     #| Split-Path -Leaf 


    } 
} | Export-Csv c:\Letters\BIZ.csv -NoTypeInformation 
+0

我说这和它的工作,我能达到我想要的。 – HushMamba

1

试试这个。你可以删除行你不想

Get-Childitem -path \\lettertext\BIZ -Recurse -Include *.txt | 
ForEach-Object { 
    $Parts = $_.fullname.split('\')[4..7] 
    [PSCustomObject]@{ 
     Customer = $Parts[0] 
     ClientGroup = $Parts[1] 
     Client = $Parts[2] 
     ClientDivision = $Parts[3] 
     FileName = $_.name 
     CreationTime = $_.CreationTime 
     CreationTimeUtc = $_.CreationTimeUtc 
     LastAccessTime = $_.LastAccessTime 
     LastAccessTimeUtc = $_.LastAccessTimeUtc 
     LastWriteTime = $_.LastWriteTime 
     LastWriteTimeUtc = $_.LastWriteTimeUtc 
    } 
} | Export-Csv c:\Letters\BIZ.csv -NoTypeInformation 
+0

虽然这可以做到;它增加了更多的细节, – HushMamba

相关问题