Andy Andy
asked on
Hide External contact
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
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
ASKER
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
Just test it on one user in the csv initially
What output would you require?
What output would you require?
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 -Hiddenfromaddresslistenab led $true}
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 -Hiddenfromaddresslistenab
For output
Export a list for contacts hidden from GAL by running the following cmdlet:
Command:
Get-Mailcontact -Filter {HiddenFromAddressListsEna bled -eq $true} | Select identity,alias,HiddenFromA ddressList sEnabled | Export-Csv -Path C:\HiddenContacts.csv -NoTypeInformation
Export a list for contacts hidden from GAL by running the following cmdlet:
Command:
Get-Mailcontact -Filter {HiddenFromAddressListsEna
ASKER
output i need in .txt file like what is the result of the script
ASKER
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 -HiddenFromAddressListsEna bled:$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..
in script folder where CSV is saved
set-adserversettings -viewentireforest:$true
import-csv hide.csv | foreach {
set-mailcontact -identity $_.PrimarySMTPAddress -HiddenFromAddressListsEna
}
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..
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
ASKER
is this tested?
what is the line 5 do.. not sure about " hidden from Address List"
what is the line 5 do.. not sure about " hidden from Address List"
Tested:
ForEach ($user in $(Get-Content C:\temp\hide.csv))
{
$change = Set-Mailbox -identity $user -HiddenFromAddressListsEnabled $true
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
in the command tested, you put Set-mailbox, i think it need to be set-mailcontact..
ASKER
awsum
You can use the:
Set-MailContact -Identity user@mydomain.com -HiddenFromAddressListsEna
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:
Open in new window