I generally do something like this. You'll need to adjust it for local norms:

                $alias = $params.emailperm.SubString( 0, 
$params.emailperm.IndexOf( '@' ) )

                $displayName = ''
                if( $params.ContainsKey( 'first_name' ) )
                {
                                $displayName += $params.first_name
                                $mbparams.FirstName = $params.first_name
                }

                if( $params.ContainsKey( 'middle_name' ) )
                {
                                if( $displayName.Length -gt 0 )
                                {
                                                $displayName += ' '
                                }
                                $displayName += $params.middle_name
                                $mbparams.Initials = $params.middle_name
                }

                if( $params.ContainsKey( 'last_name' ) )
                {
                                if( $displayName.Length -gt 0 )
                                {
                                                $displayName += ' '
                                }
                                $displayName += $params.last_name
                                $mbparams.LastName = $params.last_name
                }

                if( $displayName -eq '' )
                {
                                $displayName = $alias
                }

From: [email protected] [mailto:[email protected]] On 
Behalf Of phil levine
Sent: Monday, June 17, 2013 5:50 PM
To: [email protected]
Subject: [Exchange] CSV Import for creating Contacts

I'm trying to import a bunch of contacts and I want to populate DisplayName by 
combining FirstName and LastName, is this possible? How would I do this? I 
would also like to take FirstName and Lastname in the CSV and use it for the 
Name parameter to make it the alias, ie. Jim.Little.

Any help would be great. I always appreciate it.

Thanks

Phil

Here's an example of what I have to work with. The script works when I manually 
populate the Name and DisplayName fields.

Import-CSV C:\employees-pl.csv | ForEach-Object{New-MailContact 
-ExternalEmailAddress $_.Emailaddress -DisplayName $_.DisplayName -Name $_.Name 
-FirstName $_.FirstName -LastName $_.LastName -OrganizationalUnit $_.OUpath}

FirstName

LastName

Emailaddress

Name

DisplayName

OUPath

Anna

Little

[email protected]<mailto:[email protected]>

ad.domain.com/domain/domain contacts



Reply via email to