#==================| Satnaam Waheguru Ji |===============================  
#             
#            Author  :  Aman Dhally   
#            E-Mail  :  amandhally@gmail.com   
#            website :  www.amandhally.net   
#            twitter :   @AmanDhally   
#            blog    : http://newdelhipowershellusergroup.blogspot.in/  
#            facebook: http://www.facebook.com/groups/254997707860848/   
#            Linkedin: http://www.linkedin.com/profile/view?id=23651495   
#   
#            Creation Date    : 11-03-2014  
#            File    :          Playing with KeyBaord   
#            Purpose :  Accessing Outlook Contacts using PowerShell         
#            Version : 1   
#             
#  
#            My Pet Spider :          /^(o.o)^\    
#========================================================================  
 

 <#
  Rest of all is easy to understand. In this script,
1.    First we are adding the assemply for Microsoft Outlook.
2.    Then we are creating  com object of “Microsoft Application”
3.     Then we are getting the default MAPI namespace for outlook.
4.    Then we are binding contact folder in to “$contactObject ”
5.    After that we are using Foreach to iterate each entry in the “$contactObject ”
6.    You are saving the result in the in a custom object. 
 #>
 
BEGIN  
    { 
     
        # Try one or more commands 
        try { 
             
            # 
            Add-Type -assembly "Microsoft.Office.Interop.Outlook" -ErrorAction Stop -ErrorVariable "OutlookError" 
            $Outlook = New-Object -comobject Outlook.Application -ErrorAction stop -ErrorVariable "ApplicationError" 
            $namespace = $Outlook.GetNameSpace("MAPI") 
            $contactObject  = $namespace.GetDefaultFolder([Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderContacts) 
            $contactList = $contactObject.Items; 
        } 
         
        # Catch all other exceptions thrown by one of those commands 
        catch { 
         
            $OutlookError 
            $ApplicationError 
        } 
        # Execute these commands even if there is an exception thrown from the try block 
        finally { 
        } 
     
     
    } 
 
PROCESS  
    { 
     
 
        foreach ( $name in $contactList ) { 
         
         
            $props = @{ 
                #'Title' = $name.Title; 
                'FullName' = $name.FullName; 
                'FirstName' = $name.FirstName; 
                'Email Address' = $name.Email1Address; 
                'Mobile' = $name.MobileTelephoneNumber; 
         
         
            }     
            $object = New-Object -TypeName PsObject -Property $props 
            Write-Output $object 
            # You may find more contact field details from this link => : http://msdn.microsoft.com/en-us/library/ee160254(v=exchg.80).aspx 
 
} 
     
    } 
 
END  
    { 
     
 
    } 
 
# end of the script.