Home » Cloud » [solved] how to upload pictures in bulk to office 365/azure step by step

[solved] how to upload pictures in bulk to office 365/azure step by step

This articles will walk you thru on uploading pictures to office 365 in bulk – you would only need to do this if you do not want your users to upload their on pictures which is done via logging to the office 365 portal and uploading the pictures – the first thing that you will need to do is to get all the pictures and name them usernames and save them as jpg format since that is how I tested it

1. Open powershell and connect using the admin credentials to office 365 by using the following commands

$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
 2. create a new folder called pictures in the  root\C drive – the path would be c:\pictures. note that the picture needs to match the email alias

3.  define the path using the following command

     $path= ‘C:\pictures\
4. run the following command and you can see it picks up the pictures what are in the folder
$Images = Get-ChildItem $path
5.  run the following function is the final step and once this is completed then pictures should be uploaded by then
$Images|Foreach-Object{
$Identity=($_.Name.Tostring()-split”\.”)[0]
$PictureData=$path+$_.name
Set-UserPhoto-Identity $Identity-PictureData ([System.IO.File]::ReadAllBytes($PictureData))-Confirm:$false}
below is the final screen shot of the all the commands
below is the command to remove the picture individually for users
Remove-UserPhoto -Identity test@test.com -Whatif
(this command validates the function)
The photo for mailbox test@test.com will be removed.
Remove-UserPhoto -Identity test@test.com
Confirm
Are you sure you want to perform this action?
The photo for mailbox test@test.com will be removed.
[Y] Yes [A] Yes to All [N] No [L] No to All [?] Help (default is “Yes”): yes
One of the issue you may run into is where “Samccountname” is different than the email and if that is the case you will get an error message like below where it errors out on that the “object can not be found”
The issue here is that “email alias” does not match the login ID which is also the”Samccountname”. the if you rename the picture to match the alias name then you should not have any issue uploading the picture
Note:
Maximum size limitation is 6 to 6.5 MB
I hope this helps

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*