I'm exporting Outlook contacts to a .csv file using Powershell. Here are the relevant parts of the PS script:
$Outlook = New-Object -comobject Outlook.Application
$Contacts = $Outlook.session.GetDefaultFolder(10).items
$count = $Contacts.Count
$PSDefaultParameterValues['Out-File:Encoding'] = "utf8"
$Contacts | Select * | Export-Csv -Encoding UTF8 -NoTypeInformation "$outfile"
This is on a Windows 10 machine with Office 365. The contacts are in a local .pst file (there is no Exchange server).
It takes 15 minutes to export around 3100 contacts!
Is there a way to make this much faster? Or some other way to export these contacts?
Update:
I tried to use a "Table" object as suggested by Eugene Astafiev below, but without a filter and with Powershell instead of VB. But I cannot get any useful output with what I tried.
This for example:
$Folder = $Outlook.session.GetDefaultFolder(10)
$Table = $Folder.GetTable()
while ( $row = $Table.GetNextRow() ) { $row }
doesn't print anything useful from the contacts. It only prints
Application Class Session Parent
----------- ----- ------- ------
Microsoft.Office.Interop.Outlook.ApplicationClass 121 System.__ComObject System.__ComObject
Microsoft.Office.Interop.Outlook.ApplicationClass 121 System.__ComObject System.__ComObject
... etc.