SOLVED

Hide O365 mail contact from GAL using CSV and powershell

Steel Contributor

How to Hide O365 mail contact from GAL using CSV list and powershell

 

tried below but is looking for identity

 

Import-Csv c:\csv\disable.csv|%{Set-MailContact -Name $_.Name -HiddenFromAddressListsEnabled $true}

 

Capture.JPG

1 Reply
best response confirmed by Marvin Oco (Steel Contributor)
Solution

That's because you are using the -Name parameter, which is to change the Name attribute of the user, not to designate him as a subject to the Set-MailContact cmdlet. Use this instead:

 

Import-Csv c:\csv\disable.csv|%{Set-MailContact -Identity $_.Name -HiddenFromAddressListsEnabled $true}

 

And make sure you have a column "Name" in the CSV file.

1 best response

Accepted Solutions
best response confirmed by Marvin Oco (Steel Contributor)
Solution

That's because you are using the -Name parameter, which is to change the Name attribute of the user, not to designate him as a subject to the Set-MailContact cmdlet. Use this instead:

 

Import-Csv c:\csv\disable.csv|%{Set-MailContact -Identity $_.Name -HiddenFromAddressListsEnabled $true}

 

And make sure you have a column "Name" in the CSV file.

View solution in original post