Solved

EWS private contact

Posted on 2014-10-15
2
334 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
2 Comments
 
LVL 38

Accepted Solution

by:
Vasil Michev (MVP) earned 500 total points
Comment Utility
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
Comment Utility
""$($item.Sensitivity)"""

worked like a charm.  Appreciate the help.
0

Featured Post

Why spend so long doing email signature updates?

Do you spend loads of your time carrying out email signature updates? Not very interesting are they? Don’t let signature updates get you down. Let Exclaimer Cloud - Signatures for Office 365 make managing email signatures a breeze.

Join & Write a Comment

Synchronize a new Active Directory domain with an existing Office 365 tenant
Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
In this video we show how to create an email address policy 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 Mail Flow…
how to add IIS SMTP to handle application/Scanner relays into office 365.

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now