Hello,
I have to create Exchange 2010 mail-enabled users for people located on our Sun Iplanet Messaging server. Those users already have account in AD (based on HR number). Also I have to rewrite all their smtp addresses to MEU. I exported all data from Sun LDAP server and created csv:
User,mail,Proxyaddress,Proxyaddress2,Proxyaddress3,Proxyaddress4,Proxyaddress5,proxyaddress6
11111111,john.smith@contoso.com,j.smith@contoso.com,jsmi@contoso.com,johnny.smith@contoso.com,jsmith@contoso.com
11111112,david.brown@contoso.com,d.brown@contoso.com,,,
As you can see there are different numbers of smtp addresses per user.
I wrote a script to mail-enable listed users and to setup their email addresses:
$userobjects = import-csv "test.csv"ForEach ( $userobject in $userobjects ) {
#Assign the content to variables
$Username = $userobject.user
$mainaddress = $userobject.mail
$Proxyaddress1 = $userobject.proxyaddress
$Proxyaddress2 = $userobject.proxyaddress2
$Proxyaddress3 = $userobject.proxyaddress3
$Proxyaddress4 = $userobject.proxyaddress4
$Proxyaddress5 = $userobject.proxyaddress5
$Proxyaddress6 = $userobject.proxyaddress6
$emails = $userobject | foreach {$userobject.proxyaddress,$userobject.proxyaddress2,$userobject.proxyaddress3,$userobject.proxyaddress4,$userobject.proxyaddress5,$userobject.proxyaddress6}
enable-MailUser -identity $Username -ExternalEmailAddress $mainaddress
set-mailuser $username -EmailAddressPolicyEnabled $false
set-mailuser $username -emailaddresses $emails
}
Problem is with those different numbers of addresses because Powershell says ""MultiValuedProperty collections cannot contain null values" for everyone who don't have 6 addresses.
Is there any method to skip null values while importing csv or to skip nulls while passing it to $emails ?
Maciek Mystkowski