Solved

EWS private contact

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

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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
Marketers need statistics and metrics like everybody else needs oxygen. In this article we explain how to enable marketing campaign statistics for Microsoft Exchange mail.
In this video we show how to create an Address List 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 Organization >> Ad…
In this video we show how to create an Accepted Domain 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 >> Ac…

911 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

23 Experts available now in Live!

Get 1:1 Help Now