Skip to content

Get-MgmtGraphUserPhoto

MgmtGraph: Audits profile photo metadata for a Microsoft Graph user

#Requires -Version 5.1
#Requires -Modules Microsoft.Graph.Users

[CmdletBinding()]
Param (
    [Parameter(Mandatory = $true, Position = 0)]
    [string]$Identity
)

Process {
    try {
        $photo = Get-MgUserPhoto -UserId $Identity -ErrorAction Stop
        
        $result = [PSCustomObject]@{
            UserIdentity = $Identity
            Id           = $photo.Id
            Height       = $photo.Height
            Width        = $photo.Width
            ODataType    = $photo.AdditionalProperties.'@odata.type'
            Timestamp    = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
        }

        Write-Output $result
    }
    catch {
        throw
    }
}

Specifies the UserPrincipalName or ID of the user to audit.

An interactive directory of PowerShell scripts.