PowerShell: Script to Merge Text Files (ULS Logs) In Chronological Order By Date Modified

Updated on 2/26/2015
$inpath = "C:\Users\user\Desktop\Logs"
$outpath = "C:\Users\user\Desktop\Logs\merged.log"
Get-ChildItem -path $inpath | Sort-Object LastWriteTime | ?{ ! $_.PSIsContainer } |?{($_.name).contains(".log")} | %{ Out-File -filepath $outpath -inputobject (get-content $_.fullname) -Append}