Forum Discussion
Hjb118
Jan 29, 2022Copper Contributor
Import-CSV data into to set variables in a script
Good morning all, I don't know much about PowerShell but I am trying to create an script that variable data from each row in CSV file and input data to create the mailbox. For example: CSV: Us...
- Jan 30, 2022
Something like this, but the csv file has bob,jane as username and you should use a Firstname, Lastname colum I guess.. Now the variables are like this:
Script example:
foreach ($user in import-csv D:\temp\users.csv) { Enable-Mailbox -identity "Domainname\$($User.username)" -Database "MBDB01-$($user.servercode)" -PrimarySMTPAddress "$($user.username)@email.address" -domaincontroller "$($user).Servername" -whatif }
Jan 30, 2022
Something like this, but the csv file has bob,jane as username and you should use a Firstname, Lastname colum I guess.. Now the variables are like this:
Script example:
foreach ($user in import-csv D:\temp\users.csv) {
Enable-Mailbox -identity "Domainname\$($User.username)" -Database "MBDB01-$($user.servercode)" -PrimarySMTPAddress "$($user.username)@email.address" -domaincontroller "$($user).Servername" -whatif
}