Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Hide External contact

Posted on 2016-11-24
13
Medium Priority
?
478 Views
Last Modified: 2017-01-17
Hello Team,

Please suggest, how can i hide bulk External contact in Exchange 2013 using Powershell..
i have with me external SMTP address which is set currently. Not sure, which attribute we need to take for all user and put in CSV

Suggest the command or script

Thanks,
Andy
0
Comment
Question by:Addy Nadia
[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
  • 6
  • 5
  • 2
13 Comments
 
LVL 7

Expert Comment

by:Andy
ID: 41900214
Hi,
You can use the:
Set-MailContact -Identity user@mydomain.com -HiddenFromAddressListsEnabled $true
command to hide these as in this link:
https://robiulislam.wordpress.com/2015/06/25/hide-external-contact-from-office-365-gal/

So, place the e-mail address in a csv then read this in via a script to set them all as hidden.

Something like:
ForEach ($user in $(Get-Content C:\temp\users.txt)) 
{
	Set-MailContact -Identity $user -HiddenFromAddressListsEnabled $true 
}

Open in new window

0
 
LVL 5

Author Comment

by:Addy Nadia
ID: 41900361
how to check what this script will do and but not initiate it on any contact.. and also we need a output file also, once the script is completed when finally we need to run it
0
 
LVL 7

Expert Comment

by:Andy
ID: 41900368
Just test it on one user in the csv initially

What output would you require?
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

 
LVL 3

Expert Comment

by:Pune Tech
ID: 41900372
To export all the contacts into a csv. file use following commanr

Get-MailContact -ResultSize Unlimited | Export-Csv C:\Contacts.csv

Then use below command in powershell to hide contacts available on contacts.csv file.

Import-Csv "C:\contacts.csv" | Foreach {get-mailcontact -identity $_.Contacts -Hiddenfromaddresslistenabled $true}
0
 
LVL 3

Expert Comment

by:Pune Tech
ID: 41900373
For output

Export a list for contacts hidden from GAL by running the following cmdlet:

Command:
Get-Mailcontact -Filter {HiddenFromAddressListsEnabled -eq $true} | Select identity,alias,HiddenFromAddressListsEnabled | Export-Csv -Path C:\HiddenContacts.csv -NoTypeInformation
0
 
LVL 5

Author Comment

by:Addy Nadia
ID: 41900500
output i need in .txt file like what is the result of the script
0
 
LVL 5

Author Comment

by:Addy Nadia
ID: 41900505
Andy also confirm, is this correct as per your first comment to initiate it

in script folder where CSV is saved

set-adserversettings -viewentireforest:$true
import-csv hide.csv | foreach {

   set-mailcontact -identity $_.PrimarySMTPAddress -HiddenFromAddressListsEnabled:$true

}

also if this correct, i need output in .txt file as a result that what this command will do and what changes it will do..
0
 
LVL 7

Expert Comment

by:Andy
ID: 41900512
set-adserversettings -viewentireforest:$true
import-csv hide.csv | foreach
{
set-mailcontact -identity $_.PrimarySMTPAddress -HiddenFromAddressListsEnabled:$true
$userchange = $_.PrimarySMTPAddress " hidden from Address List"
}
$userchange | Export-CSV -Path C:\temp\UserChangeLog.csv -NoTypeInformation

Open in new window

0
 
LVL 5

Author Comment

by:Addy Nadia
ID: 41900543
is this tested?

what is the line 5 do.. not sure about " hidden from Address List"
0
 
LVL 7

Expert Comment

by:Andy
ID: 41900566
Tested:
ForEach ($user in $(Get-Content C:\temp\hide.csv))
{
$change = Set-Mailbox -identity $user -HiddenFromAddressListsEnabled $true
}

Open in new window

0
 
LVL 7

Accepted Solution

by:
Andy earned 2000 total points
ID: 41900574
This will hide any e-mail address in hide.csv then output all the hidden addresses to c:\temp\hiddenfromGAL.csv
ForEach ($user in $(Get-Content C:\temp\hide.csv))
{
Set-Mailbox -identity $user -HiddenFromAddressListsEnabled $true
}
Get-Mailbox | Where {$_.HiddenFromAddressListsEnabled -eq $True} | Select Name, HiddenFromAddressListsEnabled | export-csv c:\temp\hiddenfromGAL.csv

Open in new window

0
 
LVL 5

Author Comment

by:Addy Nadia
ID: 41900612
in the command tested, you put Set-mailbox, i think it need to be set-mailcontact..
0
 
LVL 5

Author Closing Comment

by:Addy Nadia
ID: 41904578
awsum
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
New style of hardware planning for Microsoft Exchange server.
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
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…
Suggested Courses

664 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