Exchange Online - Get-UserPhoto: ¿cómo detectar un error sin terminación?

Estoy tratando de exportar una lista de todos los usuarios sin foto de nuestra cuenta de Exchange Online usando powershell. No puedo hacer que funcione y he probado varios métodos.

Get-UserPhoto devuelve esta excepción cuando no hay un perfil presente.

Microsoft.Exchange.Data.Storage.UserPhotoNotFoundException: There is no photo stored here.

Primero de todo lo que intenté usar Errorvariable contra el comando pero recibido:

A variable that cannot be referenced in restricted language mode or a Data section is being referenced. Variables that can be referenced include the following: $PSCulture, $PSUICulture, $true, $false, and  $null.
+ CategoryInfo          : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : VariableReferenceNotSupportedInDataSection
+ PSComputerName        : outlook.office365.com

Siguiente probétrata de atraparl pero el error que no termina nunca llama alcaptur a pesar de varios métodos seguidos en línea sobre la configuración de $ ErrorActionPreference ante todo

Algunas ideas ? Aquí está el guión:

 $UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session 

$timestamp = $timestamp = get-date -Format "dd/M/yy-hh-mm"
$outfile = "c:\temp\" + $timestamp + "UserswithoutPhotos.txt"




$resultslist=@()
$userlist = get-user -ResultSize unlimited -RecipientTypeDetails usermailbox | where {$_.accountdisabled -ne $True}


Foreach($user in $userlist)
{
    try
    {

        $user | get-userphoto -erroraction stop 
    }
    catch
    {
        Write-Host "ERROR: $_"
        $email= $user.userprincipalname
        $name = $user.DisplayName
        $office = $user.office
        write-host "User photo not found...adding to list : $name , $email, $office" 
        $resultslist += $user

    }
}
$resultslist | add-content $outfile 
$resultslist

Respuestas a la pregunta(2)

Su respuesta a la pregunta