#vDM30in30,  Microsoft,  Office 365

Updating Mass Office 365 User details when not AD synced

A little while back I came across an issue where someone didnt sync their AD to Office 365 as they had two separate domains. There was quite a lot of planning and politics prior to getting one domain. All the users had their email in Office 365 but this also caused a lack of love with the details in Office 365 having two offices and domains.

My main challenge was to get the phone numbers updated in Outlook so each of the offices could easily call one another. As a bonus I also included photos of staff due to people visiting each office and all the new staff starting too. This is the reason for my main picture due to the fear of calling and everything feeling a little isolated a bit like a village.

First lets drag back some details

Set-ExecutionPolicy RemoteSigned

$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri “https://ps.outlook.com/powershell/” -Credential $cred -Authentication Basic -AllowRedirection

Import-PSSession $session
get-user | select WindowsEmailAddress,Title,Department,Office,Phone,Mobilephone | Export-CSV c:\scripts\useroutput.csv

Once this has completed open the csv file within c:\scripts\useroutput.csv, change the first tab from WindowsEmailAddress to login_name.  Update any of the required fields and save this to c:\scripts\userlist.csv

You will also need to add a photo column and in here set the path for your photo. I usually use 800×600 via IrfanView as they are then usually under the 64k JPG limit.

This is also a great time to audit your users and their details and job titles with HR as you can just send them the list.

Once you have all this you can then set the update off. You may see a load of yellow warnings if things aren’t changed but don’t worry!

Set-ExecutionPolicy RemoteSigned

$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri “https://ps.outlook.com/powershell-liveid/?proxymethod=rps” -Credential $cred -Authentication Basic -AllowRedirection

Import-PSSession $session

$user_file = Import-CSV c:\scripts\userlist.csv
$user_file | ForEach {Set-user $_.login_name -Title $_.title -Department $_.department -Office $_.office -Phone $_.Phone -Mobilephone $_.Mobilephone ; $user1 = ([Byte[]] $(Get-Content -Path $_.photo -Encoding Byte -ReadCount 0)) ; set-userphoto -identity $_.login_name -picturedata $user1 -Confirm:$false} >> c:\scripts\logfile.txt

I haven’t used this in a while and couldn’t test again but hope it helps someone out there. Use at your own risk but if you do find a way of making it better do let me know..

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.