Solved

Hide External contact

Posted on 2016-11-24
13
48 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
  • 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
 
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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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 500 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
Read this checklist to learn more about the 15 things you should never include in an email signature.
To show how to generate a certificate request 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 >> Certificates…
how to add IIS SMTP to handle application/Scanner relays into office 365.

895 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

17 Experts available now in Live!

Get 1:1 Help Now