+ Post New Thread
Results 1 to 7 of 7
Scripts Thread, Hide Disbaled Users From GAL Exchange 2010 in Coding and Web Development; Hi, I wish to create a script that will hide users from the Exchange Address list that are disabled. I ...
  1. #1

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,850
    Thank Post
    877
    Thanked 1,681 Times in 1,460 Posts
    Blog Entries
    12
    Rep Power
    445

    Hide Disbaled Users From GAL Exchange 2010

    Hi,

    I wish to create a script that will hide users from the Exchange Address list that are disabled. I have pinched a script and i can seem to get it to work. I dont get any errors. Can anyone spot the problem please?

    Thanks

    Code:
    # Add Quest / Exchange Snaps
    Add-PSSnapin Quest.ActiveRoles.ADManagement # Adds Quest "qaduser" commands
    Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 # Adds Exchange Shell Commands
    
    # Squelches error
    $ErrorActionPreference="SilentlyContinue"
    
    $user = get-qaduser -SearchRoot "falinge.int/Staff User Accounts" -disabled -NotMemberof "No Auto Disable" -anr "SMTP:*" -ldapfilter "(!(msExchHideFromAddressLists=*))" -sizelimit 0 | select samaccountname
    
    foreach($name in $user){
    set-mailbox -HiddenFromAddressListsEnabled $True -identity $name.samaccountname
    }
    
    # Force update of OAL Generator
    Get-OfflineAddressBook | Update-OfflineAddressBook
    
    # Pause script for 30 seconds
    Start-Sleep -s 30
    
    # Force update of OAB on CAS
    Get-ClientAccessServer | Update-FileDistributionService

  2. #2
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,999
    Thank Post
    120
    Thanked 280 Times in 258 Posts
    Rep Power
    106
    What errors though? Have you put the modules in the right place? Do you have your execution policy set correctly?

  3. #3
    DMcCoy's Avatar
    Join Date
    Oct 2005
    Location
    Isle of Wight
    Posts
    3,439
    Thank Post
    10
    Thanked 490 Times in 430 Posts
    Rep Power
    111
    Assume you have the Quest powershell commands installed, probably from here PowerShell Commands (CMDLETs) for Active Directory by Quest but i've never used them.

  4. #4

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,850
    Thank Post
    877
    Thanked 1,681 Times in 1,460 Posts
    Blog Entries
    12
    Rep Power
    445
    Quote Originally Posted by DMcCoy View Post
    Assume you have the Quest powershell commands installed, probably from here PowerShell Commands (CMDLETs) for Active Directory by Quest but i've never used them.
    They are indeed, i use them for another script.

    Do you have your execution policy set correctly?
    Yep it is setup ok.

    Have you put the modules in the right place?
    How do you mean please?

    What errors though?
    No errors at all.

    Thanks
    Last edited by FN-GM; 5th June 2012 at 01:44 PM.

  5. #5


    Join Date
    Feb 2007
    Location
    51.405546, -0.510212
    Posts
    8,778
    Thank Post
    223
    Thanked 2,633 Times in 1,940 Posts
    Rep Power
    780
    Quote Originally Posted by FN-GM View Post
    I don't get any errors. Can anyone spot the problem please?
    Try setting the $ErrorActionPreference to 'Stop' or 'Continue' (or comment it out with a # temporarily).

    Code:
    $ErrorActionPreference="Stop"

  6. Thanks to Arthur from:

    FN-GM (5th June 2012)

  7. #6

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,850
    Thank Post
    877
    Thanked 1,681 Times in 1,460 Posts
    Blog Entries
    12
    Rep Power
    445
    Thanks, it shows an error, but i keep missing it as the window closes. How do i stop the window for closing please?

  8. #7

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,850
    Thank Post
    877
    Thanked 1,681 Times in 1,460 Posts
    Blog Entries
    12
    Rep Power
    445
    Got a screenshot quickly. The problem was ScriptingAgentConfig.xml was missing from the client. I copied it from the server and it worked fine. I made a tweak to the code and this is the final code.

    Thanks

    Code:
    # Add Quest / Exchange Snaps
    Add-PSSnapin Quest.ActiveRoles.ADManagement # Adds Quest "qaduser" commands
    Add-PSSnapin Microsoft.Exchange.Management.Powershell.e2010 # Adds Exchange Shell Commands
    
    # Squelches error
    # $ErrorActionPreference="SilentlyContinue"
    
    $user = get-qaduser -SearchRoot "falinge.int/Staff User Accounts" -disabled -NotMemberof "No Auto Disable" -anr "SMTP:*" -ldapfilter "(!(msExchHideFromAddressLists=*))" -sizelimit 0 | select samaccountname
    
    foreach($name in $user){
    set-mailbox $name.samaccountname -HiddenFromAddressListsEnabled $true
    }
    
    # Force update of OAL Generator
    Get-OfflineAddressBook | Update-OfflineAddressBook
    
    # Pause script for 30 seconds
    Start-Sleep -s 30
    
    # Force update of OAB on CAS
    Get-ClientAccessServer | Update-FileDistributionService

SHARE:
+ Post New Thread

Similar Threads

  1. [EXCHANGE 2007] Hide disabled users from GAL
    By glennda in forum Enterprise Software
    Replies: 6
    Last Post: 27th May 2012, 11:28 AM
  2. Deny User From Own Exchange Mailbox - Banning Students
    By FN-GM in forum Enterprise Software
    Replies: 15
    Last Post: 20th May 2012, 12:03 PM
  3. Option to Hide user from global address list in MS Exchange
    By Andie in forum Windows Server 2000/2003
    Replies: 9
    Last Post: 14th October 2009, 03:32 PM
  4. Hide Staff emails from students with exchange 2003
    By bilbo in forum Network and Classroom Management
    Replies: 19
    Last Post: 8th March 2009, 11:14 AM
  5. Replies: 4
    Last Post: 11th October 2007, 12:50 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •