I am trying to send Powershell write-host output into new file after executing the command this command creating a blank file
gci -r | % { Write-Host $_.Name,$_.FullName,$_.LastWriteTime } |ft -wrap | out-file output.txt
i want FileName and File Full Path and Last Write Time in output file like this
170801072740IMG-20170622-WA0012 (1).jpg O:\170801072740IMG-20170622-WA0012 (1).jpg 1/14/2021 4:3
170801072756IMG-20170622-WA0014.jpg O:\170801072756IMG-20170622-WA0014.jpg 1/14/2021 4:35:22 PM
170801072818IMG-20170624-WA0028.jpg O:\170801072818IMG-20170624-WA0028.jpg 1/14/2021 4:35:22 PM
Excluding Properties Names:
Mode LastWriteTime Length Name
---- ------------- ------ ----
also checked with antoher command which is Write-Output
gci -r | % { Write-Output $_.Name,$_.FullName,$_.LastWriteTime } >> output2.txt
this command is redirecting output but the output is not in right format
Output file:
Tuesday, March 9, 2021 1:14:42 AM
151104051548IMG_20151103_112015.jpg
O:\151104051548IMG_20151103_112015.jpg
Friday, March 12, 2021 8:40:15 PM
151104051558IMG_20151103_123234.jpg
O:\151104051558IMG_20151103_123234.jpg
Thursday, January 14, 2021 4:35:16 PM
151104051610IMG_20151103_123249.jpg
O:\151104051610IMG_20151103_123249.jpg
Thursday, January 14, 2021 4:35:16 PM
i have also tried with Start-Transcript method but again output is not in right format
Is there any way to fix this issue?

Write-Hostcompletely and just write the values directly to file?gci -r | % { $_.Name,$_.FullName,$_.LastWriteTime -join ' ' } |Out-File .\path\to\file.txtNameandFull NameandLast Write Time