I am using PowerShell Studio 2017. I currently have a list view with 5 columns that auto fill when i launch the form. I am needing to export all of the data in that list view to a CSV file and have it formatted exactly like the list view.
It looks like this:
Username | Associate | Title | Manager | Department
Here is how the list view gets populated:
Code: Select all
$searcher = [adsisearcher]"(samaccountname=$Content)"
foreach ($DirectReportDN in $searcher.FindAll().Properties.directreports)
{
$DirectReport = [adsi]"LDAP://$DirectReportDN"
$Username = $DirectReport.Properties.samaccountname
$Associate = $DirectReport.Properties.name
$Title = $DirectReport.Properties.title
$Mgr = $DirectReport.Properties.extensionattribute6
$Dept = $DirectReport.Properties.department
Add-ListViewItem -ListView $listview2 -Items $Username -Group $listview2.Groups[0] -SubItems "$Associate", "$Title", "$Mgr", "$Dept"
}
Code: Select all
$listview2.Items | Export-Csv -Path C:\Temp\Test.csv -NoTypeInformation
Code: Select all
$listview2.Items.Text | Export-Csv -Path C:\Temp\Test.csv -NoTypeInformation
Code: Select all
$listview2.Items[0..5].Text | Export-Csv -Path C:\Temp\Test.csv -NoTypeInformation
Nothing has been working so far and i have not been able to find a reliable solution. Any help would be appreciated. Thanks.