Manage Presence Status in Microsoft Teams Using MS Graph PowerShell

Manage Presence Status in Microsoft Teams Using MS Graph PowerShell

In the realm of modern-day digital communication, Microsoft Teams plays a pivotal role within organizations. As we reach out to our colleagues through calls or messages in Teams, it has become a regular practice to glance at the small green tick.

This tiny yet significant indicator referred to as the “presence status” in Microsoft Teams, serves to convey the user’s current availability under their profile. By understanding this status, coworkers can discern their peers’ availability status within Teams, facilitating more effective and considerate communications.

Talking about this nifty feature, retrieving, changing, or managing them under the Teams admin center is not feasible for admins. Besides the Teams admin center, admins can also manage Teams using MS Graph PowerShell effortlessly.

Therefore, now easily manage the presence status of Microsoft Teams users using MS Graph PowerShell. This blog will walk you through every aspect of managing presence status in Teams using MS Graph PowerShell.

Presence Status in Microsoft Teams

Usually, this presence status can be app-configured based on the user activity, otherwise, it can be manually set in Microsoft Teams as user configured. The presence status gets updated in web and desktop versions in real time. And in the case of mobile phones, you can get the real-time status once after refreshing the page.

How to Set Presence Status in Microsoft Teams?

It is essential to configure presence status while you are attending important meetings or calls to avoid unnecessary interruptions in your workflow. As the presence status may be available in your Microsoft Teams and you are in a conference room attending the meeting and viewing the files shared via MS Teams. In such situations, configuring your presence status is crucial to notify that you are occupied with some other tasks.

Let us see how to manually set presence status in Microsoft Teams in this section.

  1. As the initial step, open your Microsoft Teams profile picture (at the right corner of your new Teams page).

profile settings to set presence status in Microsoft Teams

2. After selecting your profile, you can see the Microsoft Teams status icon and your current availability status.

available presence status in Microsoft Teams

3. Now select the drop-down button to configure the presence status of your choice in your Teams.

Various presence status in Microsoft Teams

4. Finally, the availability status is set in your Teams. You can have your duration period along with the presence status which reset the status after the allotted time period.

Duration setting

Available Presence Status in Microsoft Teams

In Microsoft Teams, presence status can be of two types: user configured, and app configured presence status. These two types of presence status are discussed in detail under this section.

User Configured Presence Status in Teams

The presence status that is manually set by the Microsoft Teams user is known as the user configured presence status. The following are the available status that a user can set in Microsoft Teams.

  • Available
  • Busy
  • DoNotDisturb
  • Away
  • BeRightBack
  • Appear Offline

App Configured Presence Status in Teams

Apart from user configured presence status, Microsoft also displays a presence status based on user activity in Microsoft Teams. The app-configured status shows an elaborate presence status based on user activity. Below is the list of presence status including activity shown by the Microsoft Teams.

Availability Activity
Available Available
Available, Out of Office
Busy Busy
Out of Office
In a Call
In a Meeting
On a Call
Do Not Disturb Presenting
Focusing
Away Away
Away Last Seen Time
Appear Offline Offline
Status Unknown
Out of Office

Manage Presence Status in Microsoft Teams Using MS Graph PowerShell

In order to retrieve the real-time status of users or change presence status in unusual situations, admins can leverage the power of Microsoft Graph PowerShell.

Install Microsoft Graph Beta Module in your PowerShell environment before digging deep into each cmdlet. Following are the operations that can be carried out on availability status using MS Graph PowerShell.

  1. Get Presence Status for a Single Teams User
  2. Get Presence Status for Multiple Teams Users
  3. Set Presence Status in Microsoft Teams
  4. Clear Presence Status in Microsoft Teams
  5. Set User Preferred Presence Status in MS Teams
  6. Clear User Preferred Presence Status in MS Teams

Pre-Requisites

Certain permissions are required to view or modify user presence in Teams which are listed below.

  • Delegated (work or school account) – Presence.Read, Presence.Read.All
  • Delegated (work or school account) – Presence.ReadWrite

You can use the below cmdlet to assign the required delegated permissions for retrieving the presence status of a Microsoft Teams user.

Connect-MgGraph –Scope <Required Permission> 

For example, in this case, the required permission is “Presence.Read.All” for admins.

Connect-MgGraph –Scope Presence.Read.All 

Permissions for setting presence status in Microsoft Teams

1. Get Presence Status for a Single Teams User

Now you can get your presence status or for any other user by running the “Get-MgBetaUserPresence” cmdlet with adequate permissions. Replace the user ID with your desired ID before running the cmdlet to retrieve the real-time presence status of the corresponding user.

Import-Module Microsoft.Graph.Beta.CloudCommunications 

Get-MgBetaUserPresence -UserId <userId> 

Note: A User Principal Name can also be used as ‘UserId’ in this cmdlet

Get presence status for a single user

2. Get Presence Status for Multiple Teams Users

Run the following cmdlets along with Get-MgBetaCommunicationPresenceByUserId” cmdlet to retrieve the presence status of multiple Teams users. Admins with appropriate permissions can read the availability status of all users to ensure they are legitimate and properly configured.

 
Import-Module Microsoft.Graph.Beta.CloudCommunications 

$params = @{ 

ids = @( 

"<UserOneID>" 

"<UserTwoID>" 

"<UserThreeID>" 

) 

} 

Get-MgBetaCommunicationPresenceByUserId -BodyParameter $params

Get availability status for multiple users

3. Set Presence Status in Microsoft Teams

Basically, a user can have different presence statuses in Teams when they have multiple Teams clients, such as on desktop, mobile, and app. The presence status in Teams client is a combined view of the overall presence status in Teams client. Thus, a user can set presence status because the user-preferred status has more precedence than the session-level presence status. And the session-level presence status has the precedence level for each activity as follows.

DoNotDisturb > Busy > Available > Away

Most importantly, users can configure some app-configured presence status in Microsoft Teams using this cmdlet in MS Graph PowerShell. This method helps to describe the user state in depth rather than the surface level user-configured availability status.

Import-Module Microsoft.Graph.Beta.Users.Actions  

$params = @{   

     sessionId = "22553876-f5ab-4529-bffb-cfe50aa89f87"  
     availability = "Available"   
     activity = "Available"   
     expirationDuration = "PT1H" 
 }  
Set-MgBetaUserPresence -UserId $userId -BodyParameter $params 

Replace the session ID with the application ID and enter desired user ID before setting the presence status in MS Teams. Therefore, change your presence status in Teams using this “Set-MgBetaUserPresence” cmdlet.

Set presence status in Microsoft Teams

Note: Expiration duration is configured to keep the presence session prevalent for the desired time and then move to Offline status. Also, note that it takes time to reflect the updated presence status in Microsoft Teams.

4. Clear Presence Status in Microsoft Teams

Now you can clear the availability status in MS Teams effortlessly using the below PowerShell cmdlets. Moreover, if a user’s only presence session is cleared using this method, then their presence status in Microsoft Teams is changed to Offline.

Import-Module Microsoft.Graph.Beta.Users.Actions  

$params = @{   

sessionId = "22553876-f5ab-4529-bffb-cfe50aa89f87"  

}  

Clear-MgBetaUserPresence -UserId $userId -BodyParameter $params 

Execute this “Clear-MgBetaUserPresence” cmdlet only after replacing the session ID with the application ID and entering the user ID in the respective place.
Clear presence status

5. Set User Preferred Presence Status in Teams Using PowerShell

User-preferred presence is the presence status set by users manually or created through the PowerShell method by setPresence operation. So now you can use the below Mg Graph PowerShell cmdlets to set the user-preferred presence in Microsoft Teams after entering the user ID. This operation will only work if the user has at least one presence session priorly. Otherwise, the user’s presence status in MS Teams will become Offline.

Import-Module Microsoft.Graph.Beta.Users.Actions  

$params = @{   
            availability = "DoNotDisturb"   
            activity = "DoNotDisturb"   
            expirationDuration = "PT8H"  
  }  
Set-MgBetaUserPresenceUserPreferredPresence -UserId $userId –BodyParameter $params 

Thus, utilize the Set-MgBetaUserPresenceUserPreferredPresence” cmdlet to set the user-preferred Teams presence status after giving the user ID as input. Thereby effectively managing presence status in Teams chat, and meetings.

Set user preferred presence status

6. Clear User Preferred Presence Status in MS Teams Using PowerShell

Clear the user-preferred presence status such as their availability and activity by running the “Clear-MgBetaUserPresenceUserPreferredPresence” PS cmdlet. Make sure you enter your user ID before executing the cmdlets. Through this operation, you can have custom presence status in Teams.

Import-Module Microsoft.Graph.Beta.Users.Actions  

$params = @{} 

Clear-MgBetaUserPresenceUserPreferredPresence -UserId $userId 

Clear user-preferred presence

Actual Presence Status isn’t Reflected in MS Teams

Sometimes, your actual presence status isn’t reflected in Teams due to various factors. Think of a scenario, in which your presence status becomes Away when your desktop was inactive. And when you are back online, the presence status doesn’t transform into an Available state.

Desktop is considered to be inactive when you lock your computer, Teams mobile app is running in the background, or when the computer enters idle/sleep mode. And the cause of these presence status issues also might be the irregular/occasional installation of Teams updates.

Thus, we can resolve the issues and make MS Teams stay green by following the methods below.

  • Try updating your Teams by selecting your profile picture and then choosing the “Check for updates” option to stop Microsoft Teams from showing away.
  • Next, you can wait for three minutes once your desktop becomes active. And then check whether the presence status in Teams is updated.
  • Otherwise, you need to raise a support ticket in Microsoft as admin. The user sign-in address, desktop, and debug log files have to be submitted when you open a support ticket. Also, the UTC time that was expected to show the presence status has to be fetched from the symptoms section and collected logs. The captured UTC time should also be submitted along with other requirements.
  • Apart from this, Microsoft 365 admins can use the self-diagnostic tools available in the tenant to run tests on Teams presence and verify the issues.

run diagnostic tool

In conclusion, deploying MS Graph PowerShell empowers administrators to seamlessly manage the availability status of Microsoft Teams users. These MS graph PowerShell cmdlets enable easy retrieval, setting, and clearing of presence statuses, fostering effective collaboration and interactions without unnecessary intrusions. By avoiding internal conflicts and disputes caused by intrusive actions, this approach ensures a harmonious environment for Teams users.

Apart from monitoring users’ presence status, you can also schedule Teams chat messages to avoid collaboration with peers during Out-of-Office hours.

I hope this blog has provided deeper insights into how to manage presence status in Microsoft Teams using simple MS graph PowerShell cmdlets. Share your experience through the comments section.

Manage Presence Status in Microsoft Teams Using MS Graph PowerShell

by Shan time to read: 7 min
0