Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Hide External contact

Posted on 2016-11-24
13
Medium Priority
?
586 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
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

 
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

WatchGuard Case Study: NCR

With business operations for thousands of customers largely depending on the internal systems they support, NCR can’t afford to waste time or money on security products that are anything less than exceptional. That’s why they chose WatchGuard.

Question has a verified solution.

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

If you have come across a situation where you need to find some EDB mailbox recovery techniques, then here you will find the same. In this article, we will take you through three techniques using which you will be able to perform EDB recovery. You …
There can be many situations demanding the conversion of Outlook OST files to PST format and as such, there is no shortage of automated tools to perform this conversion. However, what makes Stellar OST to PST converter stand above the rest? Let us e…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Loops Section Overview

963 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