Contact Manager for Azure Automate

When using Outlook and Microsoft 365, it can sometimes be annoying when a college calls and it displays as “Caller ID unknown” this is because the GAL (Global Address List) is not downloaded to the phone, it is only searchable. So you can search for a college and find the contact information. But when they call, you have no info on the caller.

I have built a Contact Manager for Azure Automate. It´s available on my Github. It is built for small companies, 200 users took about 1 hour to complete.
The Contact Manager will:

  • Add a contact folder to each user mailbox of users in a specified Users Group.
  • It will then add Contacts to that folder for every user in a specified Contacts Group.
  • Finally it will send an email report to all users in a specified Notifys Group with a log attached

After execution, all users have a personal contact folder with personal contacts for each college. When a college calls it can show the name and other information from the contact. Much more user friendly and a better experience.

The script is built with PowerShell 5.1 and uses six powershell modules:

  • Microsoft.Graph.Authentication
  • Microsoft.Graph.Groups
  • Microsoft.Graph.Users
  • Microsoft.Graph.PersonalContacts
  • Microsoft.Graph.Users.Actions
  • PsLogLite

It will run as a runbook in Azure Automation with a System Assigned Managed Identity.
The Managed Identity also needs 4 permissions in Azure AD:

  • Group.Read.All
  • User.Read.All
  • Contacts.ReadWrite
  • Mail.Send

Implement Contact Manager in Azure Automation

Azure Automation is a fantastic tool to use to schedule automations in your organization.

  1. Open Azure Portal
  2. Create a new Azure Automation Account
  1. Select System assigned managed identity
  1. And you can keep the Public network access
  1. When the account is ready, open it up
  2. Select Modules node and click Add Module
  1. Add these modules from Gallery in Runtime Version 5.1:
  • Microsoft.Graph.Authentication
  • Microsoft.Graph.Groups
  • Microsoft.Graph.Users
  • Microsoft.Graph.PersonalContacts
  • Microsoft.Graph.Users.Actions
  • PsLogLite
  1. Select Runbooks node and click Create a Runbook
  1. Give the runbook a suitable name “ContactManager” and select PowerShell with runtime version 5.1
  1. Download the script contactmanager.ps1 from my Github and paste it in your Runbook.
  2. Modify the variables in region –[Modifiable Parameters and defaults]– to suit your environment
  3. You need to create the tree groups, populate them with users and copy the groups object ID´s to the config.
  1. The last thing missing is permissions for your Managed Identity. This needs to be added manually with another PowerScript.
  2. Download the script ContactManagerScopeRights.ps1 from my Github
  3. Change the two first lines to fit your environment.
$TenantID = "11111-08a2-4ade-9a68-0db7586d80ad"
$ManagedIdentity = "Tbone-Automate"
  1. Run the script in PowerShell
  1. Go back to your automation account
  2. Open your RunBook
  3. Click Edit
  4. Change the setting $GlobalRunMode= “Test” to run in Test mode and no real changes are made
  5. Now you can click Test Pane
  6. And run the script to see the results.
  7. If it works as expected, change back $GlobalRunMode= “Prod”
  8. Publish the script and schedule the script to run every day.

Script can be found here ContactManager.ps1 from my Github

About The Author

Mr T-Bone

Torbjörn Tbone Granheden is a Solution Architect for Modern Workplace at Coligo AB. Most Valuable Professional (MVP) on Enterprise Mobility. Certified in most Microsoft technologies and over 23 years as Microsoft Certified Trainer (MCT)

You may also like...