Write-Host "msgId=$msgId"
I'm trying to get a list of only unread emails. I'm able to get the list of emails, but I'm unclear how to add the -Filter parameter.
I've tried each of the following:
$result = Get-MgUserMessage -UserId $email -Filter "IsRead=False"
$result = Get-MgUserMessage -UserId $email -Filter "IsRead=false"
$result = Get-MgUserMessage -UserId $email -Filter "IsRead='false'"
$result = Get-MgUserMessage -UserId $email -Filter "IsRead=$false"
$result = Get-MgUserMessage -UserId $email -Filter "IsRead -eq $false"
I have also tried "isRead" instead of "IsRead" in each of the above. There are some many permutations of how they might have done it, but no examples here: https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.mail/get-mgusermessage?view=graph-powershell-1.0 It just says to pass a string.
All the above attempts return:
Get-MgUserMessage : Invalid filter clause
I'm able to view the IsRead proprety like this, but I my goal is to only get the emails that are not read.
foreach ($item in $result)
{
$msgId = $item.id
$isRead = $item.IsRead
Write-Host "msgId=$msgId"
Write-Host "isRead=$isRead"
}