[Quick Links] |
Search Site

Site Details

rendered in 0.0689 secs

Captain's Log | Thursday 25th of August 2016

===============================
Office 365 Portal via Browser
===============================
Log into https://portal.microsoftonline.com using tenant account.
In the top menu bar, click on Admin and then Exchange
On the left, click Permissions
Click on the plus sign to add a new Role Group
A. Name: Address List Management
B. Roles: add “Address List” role
C. Members: add your global admin account as a member
D. Save the role group

==================================
Office 365 Portal via PowerShell | not digitally signed
==================================
Set-ExecutionPolicy Unrestricted

$cred = Get-Credential

Connect-MsolService -cred $cred

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $cred -Authentication Basic -AllowRedirection

Import-PSSession $Session

Set-TransportConfig -AddressBookPolicyRoutingEnabled $true
Get-TransportConfig | fl AddressBookPolicyRoutingEnabled

=======================
Address List creation
=======================
New-AddressList -Name "AL_Staff" –DisplayName “School Staff” -RecipientFilter { (((RecipientType -eq 'UserMailbox') -and (CustomAttribute15 -eq 'Staff'))) -or (((RecipientType -eq 'MailUniversalDistributionGroup ') -and (CustomAttribute15 -eq 'Staff')))}

New-AddressList -Name "AL_Students" –DisplayName “School Students” -RecipientFilter "RecipientType -eq 'UserMailbox' -and CustomAttribute15 -eq 'Student'"

New-AddressList -Name "AL_Resources" –DisplayName “School Room List” -RecipientFilter "RecipientDisplayType -eq 'ConferenceRoomMailbox' -and CustomAttribute15 -eq 'Room'"

Get-AddressList

==============
GAL creation
==============
New-GlobalAddressList -Name “GAL_Staff” -RecipientFilter "CustomAttribute15 -eq 'Staff'"

New-GlobalAddressList -Name “GAL_Students” -RecipientFilter "CustomAttribute15 -eq 'Student'"

Get-GlobalAddressList

==============
OAB creation
==============
New-OfflineAddressBook -Name “OAB_Staff” -AddressLists “GAL_Staff”

New-OfflineAddressBook -Name “OAB_Students” -AddressLists “GAL_Students”

Get-OfflineAddressBook

==============
ABP creation
==============
New-AddressBookPolicy -Name “ABP_Staff” -AddressLists “AL_Staff”, “AL_Students” -OfflineAddressBook “OAB_Staff” -GlobalAddressList “GAL_Staff” -RoomList “AL_Resources”

New-AddressBookPolicy -Name “ABP_Students” -AddressLists “AL_Students” -OfflineAddressBook “OAB_Students” -GlobalAddressList “GAL_Students” -RoomList “AL_Resources”

Get-AddressBookPolicy

Remove-AddressBookPolicy -Identity "ABP_Staff"

=========================
Assign ABPs to AD Users
=========================
Get-Mailbox -Filter {(CustomAttribute15 -like "Staff")} | Set-Mailbox -AddressBookPolicy "ABP_Staff"

Get-Mailbox -resultsize unlimited | where {$_.CustomAttribute15 -eq “Staff”} | Set-Mailbox -AddressBookPolicy “ABP_Staff”

Get-Mailbox -resultsize unlimited | where {$_.CustomAttribute15 -eq “Student”} | Set-Mailbox -AddressBookPolicy “ABP_Students”

Get-Mailbox -resultsize unlimited | where {$_.CustomAttribute15 -eq “Staff”} | fl displayName, AddressBookPolicy

Get-Mailbox -resultsize unlimited | where {$_.CustomAttribute15 -eq “Staff”} | Set-Mailbox -AddressBookPolicy $null

  where not equal to example !=
Get-Mailbox -resultsize unlimited | where {$_.CustomAttribute15 -nq “Student”} | Set-Mailbox -AddressBookPolicy "ABP_Staff"

=====================
On-Premise via ADUC
=====================
Create a user called "365student@school.sch.uk" and set ExtensionAttribute15 to"Student"
Create a user called "365staff@school.sch.uk" and set ExtensionAttribute15 to"Staff"

===========================
On-Premise via PowerShell
===========================
Import-Module ActiveDirectory

Get-ADUser -Filter * -SearchBase "OU=Staff,OU=MainOU OU,DC=domain,DC=sch,DC=uk" | Set-ADUser -Replace @{ExtensionAttribute15="Staff"}

Get-ADUser -Filter * -SearchBase "OU=Student,OU=MainOU OU,DC=domain,DC=sch,DC=uk" | Set-ADUser -Replace @{ExtensionAttribute15="Student"}

Get-ADGroup -Filter * -SearchBase "OU=Group,OU=MainOU OU,DC=domain,DC=sch,DC=uk" | Set-ADGroup -Replace @{ExtensionAttribute15="Staff"}

Get-ADGroup

======
Notes
======
Use $null is arguments where a deletion is required.

======================
Maintenance Commands
======================
Get-Mailbox -resultsize unlimited | { Where $._AddressBookPolicy -eq [ABP Name] }
Get-Mailbox -resultsize unlimited -SoftDeletedMailbox | { Where $._AddressBookPolicy -eq [ABP Name] }
Get-Mailbox -resultsize unlimited | where {$_.CustomAttribute15 -eq “Staff”} | fl displayName, AddressBookPolicy

Set-AddressBookPolicy -Identity "ABP_Staff" -AddressLists @{Add="AL_Site1_Staff","AL_Site2_Staff"}
Set-AddressBookPolicy -Identity "ABP_Staff" -AddressLists @{Remove="AL_Site1_Staff","AL_Site2_Staff"}
Set-AddressBookPolicy -Identity "ABP_Staff" -AddressLists @{Remove=AL_Site1_Staff","AL_Site2_Staff";Add=AL_Site3_Staff","AL_Site4_Staff"}
Set-AddressBookPolicy -Identity "ABP_Staff" -OfflineAddressBook \OAB_Staff -GlobalAddressList "\GAL_Staff" -RoomList "\AL_Resources"
note: when looking at add a group to the address book policy in the past, I came across this which suggests you can't run the add@ command, but need to note who exists in the group already and then just run the command with all members.

=====================
Comparison operators
=====================
-eq             Equal
-ne             Not equal
-ge             Greater than or equal
-gt             Greater than
-lt             Less than
-le             Less than or equal
-like           Wildcard comparison
-notlike        Wildcard comparison
-match          Regular expression comparison
-notmatch       Regular expression comparison
-replace        Replace operator
-contains       Containment operator
-notcontains    Containment operator
-shl            Shift bits left (PowerShell 3.0)
-shr            Shift bits right – preserves sign for signed values.(PowerShell 3.0)
-in             Like –contains, but with the operands reversed.(PowerShell 3.0)
-notin          Like –notcontains, but with the operands reversed.(PowerShell 3.0)