by Serkantek at 2012-11-21 21:34:46
Hi Guys,by Klaas at 2012-11-22 02:03:16
I’m new to powershell scripting and I need some assistance.
I’ve been working on a script to find all files last modified 2009-01-01 and their size. I’ve put together this script which is working but I need to tweak it to seperate the size of the file into a seperate column so I can calculate how big the files are:
Get-ChildItem -Path D:\ -Recurse | Where-Object -FilterScript {($.LastWriteTime -lt "2009-01-01")} | Out-File H:\path.csv
I have also tried:
Get-ChildItem -Path D:\ -Recurse | Where-Object -FilterScript {$.LastWriteTime -lt "2009-01-01" -and $File.Length} | Out-File H:\path.csv
But both scripts only show the data as one block of data.
Thanks in advance
The best way is to select which properties you want and then pipe to export-csv. That creates a real csv, while out-file writes every item as a string.by Serkantek at 2012-11-22 13:16:01Get-ChildItem -Path D:\ -Recurse |
Where-Object {$_.LastWriteTime -lt "2009-01-01"} |
select name,lastwritetime,length |
export-csv H]
Please tryGet-Help Get-Childitem -Full | moreandGet-Help Export-Csv -Full | moreto read about all the options and parameters you can add.
Worked a treat.
Read the help files also very helpfully.
Thank you.