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

Hi,

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:

https://i.imgur.com/7JbUDq7.jpg

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

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

The problem I’m facing is that I need to import it as New-MailUser like in https://docs.microsoft.com/en-us/powershell/module/exchange/users-and-groups/new-mailuser?view=exchange-ps:

  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 First.Last@Company1.com
  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?

 

Thanks

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: