I am trying to get the following powershell script to output the results into a .csv. The .csv file is created but there is no data, what am I doing wrong?
$rootfolder = Get-ChildItem -recurse -Path [PATH] | where {$_.Attributes -eq 'Directory'}
foreach ($userdir in $rootfolder) {
$userdir.FullName
get-acl $userdir.FullName | foreach {write-host "The owner is : " $_.Owner -Foregroundcolor Green } | export-csv c:\powershell\test.csv
Write-Host "`n"
}