$UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/?proxyMethod=RPS -Credential $UserCredential -Authentication Basic -AllowRedirection Import-PSSession $Session #Update the user photos path here. Name of the file should be username of the Office365 user. $path= 'C:\User images\' $Images = Get-ChildItem $path $Images |Foreach-Object{ $Identity = ($_.Name.Tostring() -split "\.")[0] $PictureData = $path+$_.name Set-UserPhoto -Identity $Identity -PictureData ([System.IO.File]::ReadAllBytes($PictureData)) -Confirm:$false }