Set-AzureADUserThumbnailPhoto in Automation Runbook

Sascha Reichhardt 36 Reputation points
2021-04-08T09:44:52.96+00:00

Hello,

I try to create a Azure Automation Runbook which updates the Profile Pictures of Guest Users.

As I can not define a File in Azure Automation (or Can I?) I want to use the -ImageByteArray Argument . But I dont find any examples of that. I dont know what the Argument expects here in which format.

https://learn.microsoft.com/en-us/powershell/module/azuread/set-azureaduserthumbnailphoto?view=azureadps-2.0

# Get Azure Run As Connection Name  
$connectionName = "AzureRunAsConnection"  
# Get the Service Principal connection details for the Connection name  
$servicePrincipalConnection = Get-AutomationConnection –Name $connectionName           
  
# Logging in to Azure AD with Service Principal  
"Logging in to Azure AD…"  
Connect-AzureAD –TenantId $servicePrincipalConnection.TenantId `  
    –ApplicationId $servicePrincipalConnection.ApplicationId `  
    –CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint  
      
$Guests = Get-AzureADUser -Filter "Usertype eq 'Guest'" -All $True  
ForEach ($Guest in $Guests) {  
   # Does a profilepic exist?  
   $PhotoExists = $Null  
   Try {$PhotoExists = Get-AzureADUserThumbnailPhoto -ObjectId $Guest.ObjectId }  
       Catch {  # No - Update Pic with default Photo  
       Write-Host "Photo does not exist for" $Guest.DisplayName "- updating with default guest logo"  
       Set-AzureADUserThumbnailPhoto -ObjectId $Guest.ObjectId -ImageByteArray  
       }  
}  
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,162 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,435 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
20,186 questions
0 comments No comments
{count} votes

1 additional answer

Sort by: Most helpful
  1. Sascha Reichhardt 36 Reputation points
    2021-04-08T18:46:37.763+00:00

    I solved with FilePath and a temp file in the Runbook.

    But want to know anyway what a ImageFileArray Sample looks like

    0 comments No comments