Enable the Archive mailbox based on group membership Exchange

Problem:

You would like to enable the Archive mailbox based on group membership.

Solution:

Use the following script to set the Archive mailbox:

$g = (get-group SG-Archive).members
foreach ($m in $g) {
enable-mailbox $m.distinguishedname -Archive -ArchiveDatabase “Archive”
}

Save the script as .PS1 file and execute it using the Exchange Management Shell, when you want it as scheduled task use the following command to execute the script:

Exchange 2007: PowerShell.exe -PSConsoleFile “C:\Program Files\Microsoft\Exchange Server\Bin\ExShell.psc1” -Command “. ‘<path to script>\<YourScript>.ps1′”
Exchange 2010: PowerShell.exe -PSConsoleFile “C:\Program Files\Microsoft\Exchange Server\V14\Bin\ExShell.psc1” -Command “. ‘<path to script>\<YourScript>.ps1′”
Exchange 2013: PowerShell.exe -PSConsoleFile “C:\Program Files\Microsoft\Exchange Server\V15\Bin\ExShell.psc1” -Command “. ‘<path to script>\<YourScript>.ps1′”

 

Posted in: Exchange 2007, Exchange 2010, Exchange 2013, Microsoft

banner