Assistance needed in importing .CSV file as New-MailUser?


I need some Powershell assistance in processing the input.CSV file, so I can import it as New-MailUser into my OnPremise Exchange 2013 server.

The below screenshot shows how I get the first 3 lines of.CSV out of 100+ users:

Here’s the content of the file as .CSV:

Name ,Division,Location,Country,Company,Title,Email
Jade Haze,Hardware,AZ,US,Company1,Marketing Manager,
Vina Strashin,Hardware,VIC,AU,Company1,Software Engineer,
Elvira Mansoor,Software,TX,US,Company2,CEO,

The problem I’m facing is that I need to import it as New-MailUser like in

  1. First and Last name is just one column? How to split that so it is fitted into First and Last name field?
  2. The UPN for them to login will be
  3. The password can be set universally as the parameter -Password<u> (ConvertTo-SecureString -String ‘P@ssw0rd1’ -AsPlainText -Force)</u>

Can anyone here please help with the Powershell script?



It depends pretty much on the quality of the source data in your CSV file. If the name column ALWAYS is first name and last name with a space in between them and there is never an exeption to that you can easyly split that an use it as you like it like this:

$NameList = @(
‘Jade Haze’
‘Vina Strashin’
‘Elvira Mansoor’
foreach ($Name in NameList) { [PSCustomObject]@{ FirstName = (Name -split '\s+')[0] LastName = ($Name -split ‘\s+’)[1]

BTW: An image of code is not helpful. :wink: