Bulk Update Use Information in Microsoft 365 using PowerShell

Hi Folks, M365 has been now of the most used tool by the organization to increase their productivity. On my blog we were able to go thoroughly on how we can configure and manage M365 using GUI (through Portal) or using PowerShell.

On this blog I am back again with a few of the tweaks we can do using PowerShell to manage user information on M365. we know for any tenant that has AD (Active Directory) synced with M365 can be managed easily through local AD. But what if we do have cloud only user in M365? So, on this blog we will be going through steps on how to manage user information through PowerShell in Bulk.

The Pre-requisite for this process is, you need to have MSonline services installed on your machine. You can follow the link below from the docs to install MSonline module in your machine.

https://docs.microsoft.com/en-us/powershell/azure/active-directory/install-msonlinev1?view=azureadps-1.0

Once MSonline is installed on your machine. Open PowerShell in your machine and connect to MSonline using the steps below.

  1. Open PowerShell in your Machine
  2. Login to Microsoft 365 admin account (to use MsolUser Cmdlet)
    Connect-Msolservice (It will ask for your credentials.)
  3. Download the contents of your Exchange Global Address list to a CSV file
    get-user -resultsize unlimited |select * |export-csv c:\MS365\users.csv
  4. Remove unnecessary columns and edit what you need. (don’t delete the columns named UserPrincipalName and Identity we need to use them later.)
    In this use case I will use Set-MsolUser module, which supports the following options.

Set-MsolUser
[-ImmutableId ]
[-ObjectId ]
[-UserPrincipalName ]
[-BlockCredential ]
[-City ]
[-Country ]
[-Department ]
[-DisplayName ]
[-Fax ]
[-FirstName ]
[-LastName ]
[-LastPasswordChangeTimestamp ]
[-MobilePhone ]
[-Office ]
[-PasswordNeverExpires ]
[-PhoneNumber ]
[-PostalCode ]
[-PreferredDataLocation ]
[-PreferredLanguage ]
[-SoftDeletionTimestamp ]
[-State ]
[-StreetAddress ]
[-StrongPasswordRequired ]
[-Title ]
[-UsageLocation ]
[-AlternateEmailAddresses ]
[-StrongAuthenticationMethods ]
[-AlternateMobilePhones ]
[-StrongAuthenticationRequirements ]
[-StsRefreshTokensValidFrom ]
[-UserType ]
[-TenantId <Guid>]
 

  1. After updating the CSV, import the updated csv to PowerShell and execute the changes.

in the below script, header names referenced with a hyphen are the names we used in our sheet. header names referenced with $_. are the ones that the exchange is expecting from us. To make it simpler I used the same names as exchange in my sheet.

to map a field to a field in exchange we use this syntax: – $_.

 

 

supported field names are shown in step 5.

In this script we are using UserPrincipalName as the main reference.

After running this script, it takes a few minutes to be able to see your changes in the Exchange Admin portal.

(This note is based on what I did today. I have very little understanding of PowerShell, if you are going to try these steps, please do your research first.)

Add a Comment

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.