Solved

EWS private contact

Posted on 2014-10-15
2
362 Views
Last Modified: 2014-10-16
Hello,
 
I am using the script below to export all users fields necessary but I need to also find all users with a contact marked as private.  I cannot find any information online regarding "private" in order to complete the script.  I figured it would be best to bring it to the forums and maybe someone can help.  Any help would be appreciated. Thanks in advance.
 
[String] $AccountNames = "D:\test1.txt"
 foreach ($mbxName in Get-Content $AccountNames) {
    [Int] $intCount = 0
     $dllPath = "c:\Program Files\Microsoft\Exchange\Web Services\2.1\Microsoft.Exchange.WebServices.dll"
     [Void] [Reflection.Assembly]::LoadFile($dllPath)
 
$Service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP2)
 
$Service.AutodiscoverUrl($mbxName, {$True})
 $RootFolderID = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::contacts, $mbxName)
 
$RootFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($Service, $RootFolderID)
 
 
 
# this is the section to export contact items out of contacts folder only
 
 
 
$view = New-Object Microsoft.Exchange.WebServices.Data.ItemView(10000,0)

$findResults = $Service.FindItems($rootFolderid,$view)

 
 
foreach($item in $findResults)
 
  {
 
  """$mbxName"",""$($item.GivenName)"",""$($item.MiddleName)"",""$($item.Surname)"",""$($item.CompleteName.Suffix)"",""$($item.CompanyName)"",""$($item.PhysicalAddresses[0].Street)"",""$($item.PhysicalAddresses[0].City)"",""$($item.PhysicalAddresses[0].State)"",""$($item.PhysicalAddresses[0].PostalCode)"",""$($item.PhysicalAddresses[0].CountryOrRegion)"",""$($item.PhoneNumbers[1])"",""$($item.PhoneNumbers[2])"",""$($item.PhoneNumbers[11])"",""$($item.PhoneNumbers[9])"",""$($item.PhoneNumbers[3])"",""$($item.EmailAddresses[0].Address)"",""$($item.EmailAddresses[1].Address)"""
 
  }
 
 
 
#  this is the section to export contact items out of ALL contacts sub folder only
 
 
 
$FolderView = New-Object Microsoft.Exchange.WebServices.Data.FolderView(10)
 
$FolderView.Traversal = [Microsoft.Exchange.WebServices.Data.FolderTraversal]::Deep
 
$Response = $RootFolder.FindFolders($FolderView)
 
 
 
ForEach ($folder in $Response.Folders)
 
{
 
 
 
$view1 = New-Object Microsoft.Exchange.WebServices.Data.ItemView(10000,0)

$findResults1 = $Service.FindItems($folder.id,$view1)

 
 
foreach($item in $findResults1)
 
  {
 
  """$mbxName"",""$($item.GivenName)"",""$($item.MiddleName)"",""$($item.Surname)"",""$($item.CompleteName.Suffix)"",""$($item.CompanyName)"",""$($item.PhysicalAddresses[0].Street)"",""$($item.PhysicalAddresses[0].City)"",""$($item.PhysicalAddresses[0].State)"",""$($item.PhysicalAddresses[0].PostalCode)"",""$($item.PhysicalAddresses[0].CountryOrRegion)"",""$($item.PhoneNumbers[1])"",""$($item.PhoneNumbers[2])"",""$($item.PhoneNumbers[11])"",""$($item.PhoneNumbers[9])"",""$($item.PhoneNumbers[3])"",""$($item.EmailAddresses[0].Address)"",""$($item.EmailAddresses[1].Address)"""
 
  }
 
 
 
 
 
}
 }
0
Comment
Question by:ehanchar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 41

Accepted Solution

by:
Vasil Michev (MVP) earned 500 total points
ID: 40383732
You need to check the Sensitivity property of the item. In your example, should be $findResults1.Items[0].Sensitivity
0
 

Author Closing Comment

by:ehanchar
ID: 40384476
""$($item.Sensitivity)"""

worked like a charm.  Appreciate the help.
0

Featured Post

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to install and use the NTBackup utility that comes with Windows Server.
A list of top three free exchange EDB viewers that helps the user to extract a mailbox from an unmounted .edb file and get a clear preview of all emails & other items with just a single click on mailboxes.
In this video we show how to create a mailbox database in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Servers >> Data…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question