Solved

Hide External contact

Posted on 2016-11-24
13
31 Views
Last Modified: 2016-11-28
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:Andy Navi
  • 6
  • 5
  • 2
13 Comments
 
LVL 6

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 4

Author Comment

by:Andy Navi
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 6

Expert Comment

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

What output would you require?
0
 
LVL 2

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 2

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 4

Author Comment

by:Andy Navi
ID: 41900500
output i need in .txt file like what is the result of the script
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 4

Author Comment

by:Andy Navi
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 6

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 4

Author Comment

by:Andy Navi
ID: 41900543
is this tested?

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

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 6

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 4

Author Comment

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

Author Closing Comment

by:Andy Navi
ID: 41904578
awsum
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
This article will help you understand what HashTables are and how to use them in PowerShell.
To show how to create a transport rule 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 >> Rules tab.:  To cr…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

757 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