2016-04-25 1 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

вы можете выставить свойства/методы, что Get-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

 Смежные вопросы

  • Нет связанных вопросов^_^