Out-vCard: Exporting Outlook Address Book

Our local identity management guru Jackson Shaw tasked me with giving him an easy way to export contact information from corporate address book so you can then send it to someone for their reference. The standard format for Outlook to import contact information is vCard, but the problem is that Outlook can export to vCard only personal contacts, but not GAL entries. Needless to say, PowerShell is the answer. ;)

This is the command-line which solves the task:

Get-QADUser "Dmitry Sotnikov" | Out-vCard

This will locate a user in your AD whose name is "Dmitry Sotnikov" (which probably means you work for Quest) and create a file "Dmitry Sotnikov.vcf" at the c:\ drive root.

If you want to export all members of a DL – this will work too:

Get-QADGroupMember DL.ProjectA | Out-vCard

This will create a vCard for each DL member.

And because it only reads data from your Active Directory you don’t need any administrative privileges. This will work for any domain user.

To make this work you need to:

  1. Install PowerShell and AD cmdlets.
  2. Copy/paste the following function into PowerShell command-line shell before running the commands or add it to your profile (My Documents/WindowsPowerShell/profile.ps1):

function Out-vCard {
$input | ForEach-Object {

    $filename = "c:\" + $_.Name + ".vcf"
    Remove-Item $filename -ErrorAction SilentlyContinue
    add-content -path $filename "BEGIN:VCARD"
    add-content -path $filename "VERSION:2.1"
    add-content -path $filename ("N:" + $_.LastName + ";" + $_.FirstName)
    add-content -path $filename ("FN:" + $_.Name)
    add-content -path $filename ("ORG:" + $_.Company)
    add-content -path $filename ("TITLE:" + $_.Title)
    add-content -path $filename ("TEL;WORK;VOICE:" + $_.PhoneNumber)
    add-content -path $filename ("TEL;HOME;VOICE:" + $_.HomePhone)
    add-content -path $filename ("TEL;CELL;VOICE:" + $_.MobilePhone)
    add-content -path $filename ("TEL;WORK;FAX:" + $_.Fax)
    add-content -path $filename ("ADR;WORK;PREF:" + ";;" + $_.StreetAddress + ";" + $_.PostalCode + " " + $_.City + ";" + $_.co + ";;" + $_.Country)
    add-content -path $filename ("URL;WORK:" + $_.WebPage)
    add-content -path $filename ("EMAIL;PREF;INTERNET:" + $_.Email)
    add-content -path $filename "END:VCARD"

}
}

Note that the script is something I put together in 15 minutes to help Jackson, so it still needs a few improvements when I have time:

  1. Need to add an optional parameter for the output folder.
  2. Need to actually look at vCard spec to make sure all attributes translate right.
  3. Need to look whether I need to check whether attributes are present. Does vCard format permit empty values or should their keys be in that case omitted?

Anyways, this seems to solve the task for now, I hope I have a few hours later to make it perfect. Feel free to do so yourself if you are interested.

Tags: , , , , , ,

About these ads

6 Responses to “Out-vCard: Exporting Outlook Address Book”


  1. 1 Joel "Jaykul" Bennett November 8, 2007 at 3:58 am

    Very nice, I’ll put that to good use.

    Can’t resist saying … you ought to write it as a filter function: use the PROCESS block so you don’t hold up the pipeline ;) or have a look at my template pipeline script to do it the full featured way.

    http://huddledmasses.org/writing-better-script-functions-for-the-powershell-pipeline/

  2. 2 jdubwillie September 22, 2009 at 2:06 pm

    I’m going to take a long shot here, looking at the age of the post. I have followed the instructions and am very happy with the results. Our company uses the JPEGPHOTO AD object to store a photo of every user. I’m trying to modify the OUT-VCARD function to pull this info in, but I’m not having much luck with it. This is what I have so far:
    add-content -path $filename (“PHOTO; TYPE=JPEG; ENCODING=base64;:” + $_.JPEGPHOTO)

    Any insights or help are appreciated.

  3. 3 you may not need to carry comprehensive or collision insurance. if you still have an unpaid Loan on your car May 24, 2013 at 7:06 am

    Hi, this weekend is nice in support of me, since this point in time i am reading this
    impressive informative article here at my residence.


  1. 1 Windows PowerShell : Check it out: Out-vCard Trackback on November 7, 2007 at 9:51 pm
  2. 2 MSDN Blog Postings » Check it out: Out-vCard Trackback on November 7, 2007 at 11:45 pm
  3. 3 Powershell Add filepath to ConvertTo-HTML | blindpete.com Trackback on October 8, 2009 at 1:39 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s




My Recent Tweets

RSS My company’s blog

  • Meet our iPad2 Winner, Bruce Burke
    Last month we ran our first sweeps contest and received over 30,000 entries in just 4 weeks! Below is a screenshot of the Facebook entries: After announcing the winner, Bruce Burke, I decided to get in touch and find out more about him and how he is using Jelastic for his projects. Hi Bruce, thanks [...]The post Meet our iPad2 Winner, Bruce Burke appeared fi […]
  • MongoDB Master Slave Replication
    As we’ve already told you in our previous post about MySQL master-slave replication the database replication offers various benefits depending on its type and the options you choose, but the common benefit of replication is the availability of data when and where it is needed.  As a result, your customers will experience improved availability of replicated d […]
  • Integration with NetBeans IDE
    Like millions of developers out there we really love NetBeans IDE, which lets you quickly and easily develop Java desktop, mobile, and web applications, while also providing great tools for PHP developers. That’s why we have created a Jelastic plugin for this platform. With the new Jelastic plugin for NetBeans IDE, you can work with your development, [...]Th […]
  • New Version of Jelastic – 1.9.1 Launched
    Today we announced the launch of a major new version of Jelastic. The new version, 1.9.1, features a CRON scheduler, the ability to schedule database backups, new notifications about running out of resources and the latest versions of software stacks (including PostgreSQL 9.2.4). The newly launched Jelastic 1.9.1 includes: CRON job scheduler, Scheduled datab […]
  • Jelastic Released Commercially by innofield!
    Switzerland is well know for chocolate, their army knives and creating fabulous watches. Thanks to innofield,  the Swiss will forever be known as the providers of the first Swiss based PaaS solution with their Flow App Engine (powered by Jelastic). This week, innofield came out of beta and launched commercially with Jelastic 1.9.1. “As Platform-as-a-Service […]
  • Play 1 vs Play 2 Framework
    Today’s guest post comes to you from our friend and user, Dane Marcelo, JArchitect product manager. He points out some interesting differences between the Play 1 and the Play 2 frameworks. So, let’s dive into this great post! Play is an open source web application framework, written in Scala and Java, which follows the model–view–controller (MVC) architectur […]
  • Cloud Software Stacks Market Share: April 2013
    It’s that time where we can share with you the updated statistics on databases, Java and PHP application servers as well as Java and PHP version popularity. Last month was hot here at Jelastic: we launched Jelastic in the Netherlands with the most technically advanced hoster in the country – info.nl and in Switzerland with our very [...]The post Cloud Softwa […]

Legal

The posts on this blog are provided “as is” with no warranties and confer no rights. The opinions expressed on this site are mine and mine alone, and do not necessarily represent those of my former employer - Quest Software, or my current employer - Jelastic or anyone else for that matter. All trademarks acknowledged.

© 2007-2013 Dmitry Sotnikov

Pages

November 2007
M T W T F S S
« Oct   Dec »
 1234
567891011
12131415161718
19202122232425
2627282930  

Follow

Get every new post delivered to your Inbox.

Join 65 other followers

%d bloggers like this: