threesocks
Technical User
I'm working on the below script but can't find a way to format the results how I want. Basically I want to have the script send the results to either an csv or text file with the header information not inline with the results as I have it below (i.e. Filename would only display once as a column header with all DirectoryName's below it.
$computers = Get-Content "c:\scripts\servers.txt"
$targetDate = '9-29-2010'
$sourceRoot = 'c:\scripts2\'
$inner = ForEach ($computer in $computers) {Get-ChildItem -LiteralPath $sourceRoot -Force -Recurse `
| where-object {$_.lastWriteTime -gt $targetDate} `
| ForEach-Object {
# Echo the changes to screen so you can see what happened
#
$writetime=$_.lastwritetime
$fullname=$_.FullName
$accesstime=$_.lastaccesstime
$creationtime=$_.creationtime
$directoryname=$_.directoryname
"Filename: $_, DirectoryName: $directoryname, CreationTime: $CreationTime, LastWriteTime: $writetime, LastAccessTime: $accesstime, Computer: $computer"}
} $inner | out-file C:\Scripts2\OUTPUT3.TXT
Thanks,
Sean
$computers = Get-Content "c:\scripts\servers.txt"
$targetDate = '9-29-2010'
$sourceRoot = 'c:\scripts2\'
$inner = ForEach ($computer in $computers) {Get-ChildItem -LiteralPath $sourceRoot -Force -Recurse `
| where-object {$_.lastWriteTime -gt $targetDate} `
| ForEach-Object {
# Echo the changes to screen so you can see what happened
#
$writetime=$_.lastwritetime
$fullname=$_.FullName
$accesstime=$_.lastaccesstime
$creationtime=$_.creationtime
$directoryname=$_.directoryname
"Filename: $_, DirectoryName: $directoryname, CreationTime: $CreationTime, LastWriteTime: $writetime, LastAccessTime: $accesstime, Computer: $computer"}
} $inner | out-file C:\Scripts2\OUTPUT3.TXT
Thanks,
Sean