我想在此PowerShell脚本中添加上次修改日期和时间

时间:2016-04-25 22:35:10

标签: powershell powershell-v2.0 powershell-v3.0

var bs = new BitSet;
bs.set(128, 1); // Set bit at position 128
console.log(bs.toString(16)); // Print out a hex dump with one bit set

上面的代码为我提供了不同文件夹中的文本文件,但我还要添加最后修改日期和时间..谢谢

2 个答案:

答案 0 :(得分: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 

答案 1 :(得分: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