![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Export to csv with custom column headers I have some code which does the following: $servers = 'servera','serverb' foreach ($server in $servers){ Get-ChildItem "\\$server\c$\folder" | Select-Object name,lastwritetime } i.e. it returns all the files in the remote folder for each server and returns the name of the file and the time it was last written to. I need to extend this futher by taking the returned list of files and lastwritetime and export to a csv which has the file names as the column headers (they will be the same for each server) , the row label as the server name and the data as the lastwritetime. So far I can only get it to export to individual csv's for each server and name,lastwritetime are the column headers. Anyone able to help? Thanks |
My System Specs![]() |
| | #2 (permalink) |
| | RE: Export to csv with custom column headers Here you go. This should give you one row per server with the column heading being the filenames and the data being the last write time. One column is the name of the server as well. $servers = 'servera','serverb' $filedata = @() foreach ($server in $servers){ $files = Get-ChildItem "\\$server\c$\folder" | Select-Object name,lastwritetime $entry = new-object psobject $entry | add-member noteproperty server $server $files | foreach { $entry | add-member noteproperty $_.name $_.lastwritetime } $filedata += $entry } "jmedd" wrote: Quote: > I need to extend this futher by taking the returned list of files and > lastwritetime and export to a csv which has the file names as the column > headers (they will be the same for each server) , the row label as the server > name and the data as the lastwritetime. > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Is it possible in "computer" to view files from top to bottom in 1st column then same again in next column to the right etc? | Vista file management | |||
| Custom Mail Headers with Windows Mail | Vista mail | |||
| Export-CliXml/Export-Csv: Change to Export-Object? | PowerShell | |||