Hello there,
I am rather new to Powershell. I wrote the below code to extract properties out of some files and export to CSV.
$output = foreach ($doc in $docs)
{
$date = Get-Date
$duration = ($date - $doc.StatusChangeDate).TotalHours
$Name = $doc.FileName
$outto = $doc.DocumentOutToName
$fullpath =$doc.FullPath
$statuschange = $doc.StatusChangeDate
@($Name,$duration,$outto,$statuschange,$fullpath)
}
$output
$output | export-csv -Path "C:\Users\mypc\Desktop\Powershell\status.csv" -NoTypeInformation
I am getting the output as
1a
1b
1c
1d
1e
2a
2b
2c
2d
2e
3a …
But somehow the export to csv is not giving any output. I want the output in below format.
1a 1b 1c 1d 1e
2a 2b 2c 2d 2e
…
Also, please let me know anything I can do to enhance the quality of the code.