Table of Contents
Invite New Employees to Corporate Events
When I wrote about using attached ICS files in welcome emails to bring corporate events to the attention of new employees, I said that although it’s possible to create ICS files that Outlook will accept, this isn’t the best way to achieve the goal.
The idea is that new employees often need some help to understand the culture of their new company. By including details of corporate events like town halls, executive briefings, or HR info-sessions along with the welcome email, the new employees will have access to this information and be able to attend the events that interest them.
It’s certainly possible to load the ICS files into calendars, but it’s reasonable to expect that some users won’t know how to inserts events into their calendars. In addition, an ICS file is intended to circulate information about an event rather than the kind of meetings or online meetings used for corporate gatherings, and the event that ends up being created in the calendar belongs to the owner of the calendar rather than the event organizer.
A Better Way
It seems like a better way to achieve the goal is to simply invite the new employees to the corporate events by adding them as meeting participants. Much of the same code used in the previous script can be repurposed (to find new user accounts, find corporate events, and send email to those accounts). The big difference are the steps to add meeting participants. To do this, we:
- Find the corporate events as before (any event in a corporate meeting calendar in the next six weeks).
- For each event, find the current set of participants.
- Add the new attendees to the current participant list.
- Write the merged participant list back into the event.
Let’s look at the individual steps.
Find Corporate Events
First, we establish the calendar where corporate events are stored. This can be in a user or shared mailbox:
$CalendarUser = Get-MgUser -UserId "Corporate.Events.Meetings@office365itpros.com" $Calendar = Get-MgUserDefaultCalendar -UserId $CalendarUser.Id
Next, find events in the target calendar for the next 42 days:
$StartDateTime = (Get-Date).ToString("yyyy-MM-dd")
$EndDateTime = (Get-Date).AddDays(42).ToString("yyyy-MM-dd")
[array]$Events = Get-MgUserCalendarView -UserId $CalendarUser.Id -CalendarId $Calendar.Id -all -EndDateTime $EndDateTime -StartDateTime $StartDateTime
Create New Attendee List
The script uses the Get-MgUser cmdlet to find newly-added accounts. To add the accounts as meeting participants we need the email address and display name of each account. The information for a participant is stored in a hash table together with an indicator whether the participant is required or optional. An array holds the set of hash tables:
[array]$NewAttendees = @()
# Loop through the users we want to add to the event
ForEach ($User in $Users) {
# Create hash table containing attendee details
$NewAttendee = @{
EmailAddress = @{
Address = $User.Mail
Name = $User.displayName
}
Type = "optional" # or "required"
}
# Add the hash table to the array of new attendees
$NewAttendees += $NewAttendee
}
Created Merged Participants and Update Meetings
The script now loops through the set of events to extract the current participant list and combine it with the set of new attendees. Finally, the new employees are invited to the event by running the Update-MgUser cmdlet to update the participant list:
ForEach ($Meeting in $Events) {
# Get current attendees for the meeting
[array]$CurrentAttendees = $Meeting.Attendees
# Combine the arrays of new and existing attendees to create an updated list of attendees for the meeting
[array]$UpdatedAttendees = $CurrentAttendees + $NewAttendees
# Update the meeting to add the users as participants
$Status = Update-MgUserEvent -UserId $CalendarUser.Id -EventId $Meeting.Id -Attendees $UpdatedAttendees -ErrorAction Stop
}
Updating event participants causes Exchange Online to send email to each of the new attendees. The recipients can decide which event they’d like to attend and RSVP appropriately. The nice thing is that the meeting organizer can see who’s responded (Figure 1) and the attendees will receive any updates that might occur for their meetings. Neither of these things happen when an ICS is imported into Outlook to create an event.
Creating ICS events and sending them around as message attachments was an interesting exercise in PowerShell scripting. Inviting new employees to corporate events by adding them as participants is the easiest and most effective way of making the events available to new employees. The version of the script that invites new employees to corporate events is available in the Office 365 for IT Pros GitHub repository. Enjoy!
Need help to write and manage PowerShell scripts for Microsoft 365, including Azure Automation runbooks? Get a copy of the Automating Microsoft 365 with PowerShell eBook, available standalone or as part of the Office 365 for IT Pros eBook bundle.

