-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSet-ADHideAddressBook.ps1
More file actions
22 lines (16 loc) · 936 Bytes
/
Set-ADHideAddressBook.ps1
File metadata and controls
22 lines (16 loc) · 936 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#AD - Hide in 365 Address book when using Azure AD Sync
#https://www.tachytelic.net/2017/11/office-365-hide-a-user-from-gal-ad-sync/
#Add mail nickname for hiding addressbook
#Documentation <https://social.technet.microsoft.com/Forums/lync/en-US/6811071e-f329-428e-a70d-8f05bbe61d1d/how-to-set-aduser-attribute-mailnickname?forum=winserverpowershell
[CmdletBinding()]
param (
[Parameter(Mandatory,HelpMessage='User to hide from addressbook without @')]
[string]$Identity,
[Parameter(Mandatory)]
[ValidateNotNull()]
[System.Management.Automation.PSCredential]
[System.Management.Automation.Credential()]
$Credential = [System.Management.Automation.PSCredential]::Empty
)
Get-ADUser -Identity $Identity -Properties MailNickName | Set-ADUser -Replace @{MailNickName = "$Identity"} -Credential $Credential
Set-ADUser -Identity $Identity -Replace @{msExchHideFromAddressLists=$true} -Credential $Credential