Solved

EWS private contact

Posted on 2014-10-15
2
365 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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

After hours on line I found a solution which pointed to the inherited Active Directory permissions . You have to give/allow permissions to the "Exchange trusted subsystem" for the user in the Active Directory...
This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
how to add IIS SMTP to handle application/Scanner relays into office 365.

726 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