How to specify a group of users access a limited Address List
Introduction
This script will set a group of users with custom attribute to view a limited address list.
Scenarios
This script is to set a group of users with custom attribute to view a limited address list. For example, the student can only find other recipients in the same grade in address list.
Script
You can use this script in the following way.
1. Open Windows PowerShell.
2. Type the one command< Script Path> at the Windows PowerShell Console.
For example, type C:\Script\ SetALPolicy.ps1
Here are some code snippets for your references.
$str = "(CustomAttribute9 -eq '$Attr')"
$Filter = [scriptblock]::Create($str)
New-GlobalAddressList -name "GAL_$Name" -RecipientFilter $filter
New-OfflineAddressBook -name "OAB_$Name" -AddressLists "GAL_$Name"
New-AddressBookPolicy -name "ABP_$Name" -AddressLists $Name -OfflineAddressBook "\OAB_$Name" -GlobalAddressList "\GAL_$Name" -RoomList ("\" + $Name + "_Resources")
$str = "(CustomAttribute9 -eq '$Attr')"
$Filter = [scriptblock]::Create($str)
New-GlobalAddressList -name "GAL_$Name" -RecipientFilter $filter
New-OfflineAddressBook -name "OAB_$Name" -AddressLists "GAL_$Name"
New-AddressBookPolicy -name "ABP_$Name" -AddressLists $Name -OfflineAddressBook "\OAB_$Name" -GlobalAddressList "\GAL_$Name" -RoomList ("\" + $Name + "_Resources")
Example: The students' mailbox has customattribue9 which is filled with grade year. The following example is to create the address list for student in 2014.
The sample is showed below
SetALPolicy.ps1 -Credential $credential –Attr 2014 –Name 2014Grade
Result Screenshot:
Prerequisites
Exchange Online
Windows PowerShell 2.0
Microsoft All-In-One Script Framework is an automation script sample library for IT Professionals. The key value that All-In-One Script Framework is trying to deliver is Scenario-Focused Script Samples driven by IT Pros' real-world pains and needs. The team is monitoring all TechNet forums, IT Pros' support calls to Microsoft, and script requests submitted to TechNet Script Repository. We collect frequently asked IT scenarios, and create script samples to automate the tasks and save some time for IT Pros. The team of All-In-One Script Framework sincerely hope that these customer-driven automation script samples can help our IT community in this script-centric move.