Пытаюсь вывести список объектов массива в файл CSV. Однако я хотел бы, чтобы каталог, имя, lastwritetime и владелец были в отдельных столбцах, а не объединялись в один столбец. Не уверен, как обойти эту ситуацию. пожалуйста, смотрите текущий код ниже. Вывод в gridview и текст работает нормально, но не вывод csv.
thx.
$Path = "A:\Test"
$PathArray = @()
$Results = "A:\Test\test_results_7.csv"
$extension = "xml"
# This code snippet gets all the files in $Path that end in extension parameter.
# where the file update was made in the last 30 days
Get-ChildItem $Path -Filter "*.$extension" -recurse |
Where-object { $_.LastWriteTime -ge (Get-Date).AddDays(-30)} |
ForEach-Object {
$PathArray += -join ($_.Directory , " , " , $_.Name , " , " , $_.LastWriteTime , " , " , ((Get-ACL $_.Fullname).Owner) )
}
$PathArray += -join ("Path Location" , " , " , "File name" , " , " , "Last Write Time" , " , " , "Owner" )
#$PathArray | Out-GridView
$PathArray | select-object $PathArray | ForEach-Object {$_} | Export-csv $Results