Below is a custom script to hide an AD user from GAL (global address list) when Exchange Server schema has been removed from Active Directory.
| ############################################################## |
| # This Scrip will allow you to hide a mailbox in Ad # |
| ############################################################## |
| Import-Module ActiveDirectory |
| #Request username to use in distribution group search. |
| Write-Host "Enter username, or 'exit' to close." |
| if (($User -eq "exit") -or ($User -eq "Exit") -or ($User -eq "EXIT")) { |
| #If no exit command is entered, search for the requested user. |
| while (($User -ne "exit") -and ($User -ne "Exit") -and ($User -ne "EXIT")) { |
| $UserExists = Get-ADUser -filter {sAMAccountName -eq $User} |
| #Check if user exists, and skip search if they do not. |
| Write-Host "ERROR: That user does not exist." |
| Set-ADUser $User -Replace @{msExchHideFromAddressLists=$true} |
| #Request new user or app exit. |
| Write-Host "`nEnter username, or 'exit' to close." |
}
Comments
0 comments
Please sign in to leave a comment.