Forum Discussion

Matt_P_Standing's avatar
Matt_P_Standing
Brass Contributor
May 21, 2024
Solved

No output for Invoke-MgGraphRequest for user presence

Hi All!

 

I am experiencing some odd behaviour with a Invoke-MgGraphRequest and an Azure Runbook and could do with a nudge in the right direction.

I am trying to report on my Teams presence using GraphAPI. When I use the following code, it works, presence returned:

 

Invoke-MgGraphRequest -method GET -Uri "https://graph.microsoft.com/v1.0/communications/presences/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" 

 


But, When I try and assign this output to a variable (so it can be passed to a SharePoint list) I don't get any output:

$returned=Invoke-MgGraphRequest -method GET -Uri "https://graph.microsoft.com/v1.0/communications/presences/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
$returned.value | ForEach-Object {$_.availability}




Am I doing something wrong, or is this expected behaviour?

  • I managed to resolve myself using:

     

    $Result = (Invoke-MgGraphRequest -method GET -Uri "https://graph.microsoft.com/v1.0/communications/presences/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")

     

    I was just missing the brackets! Thanks PowerShell! :xd:

1 Reply

  • I managed to resolve myself using:

     

    $Result = (Invoke-MgGraphRequest -method GET -Uri "https://graph.microsoft.com/v1.0/communications/presences/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")

     

    I was just missing the brackets! Thanks PowerShell! :xd:

Resources