Jump to content

Recommended Posts

Posted

Hi, I was wondering if someone could spot what I'm doing wrong. I am trying to import Mail Contacts (users with external email addresses) into an OU in our AD. The OU exists and I have others there. On the command line, in Exchange 2010, I can type the following and it works fine :

 

[PS] C:\etc \etc>New-MailContact -Name "Some Person" -ExternalEmailAddress spersonATaddress.co.uk -OrganizationalUnit "brcc.local/BRCC/WsgflAccounts"

…and I get:

 

[PS] C:\etc\etc>New-MailContact -Name "Some Person" -ExternalEmailAddress sperso

nATaddress.co.uk -OrganizationalUnit "brcc.local/BRCC/WsgflAccounts"

 

Name Alias RecipientType

---- ----- -------------

Some Person SomePerson MailContact

 

I then remove this contact and try to add it through the next stage.

That’s fine for one or 2, but for 200 or so, I need a bulk import. I've read numerous Google results and so I tried this:

Import-CSV "c:\files\test.csv" | ForEach-Object { New-MailContact -Indentity $_.Name -ExternalEmailAddress $_.ExternalAddress -OrganizationalUnit $_.orgu }

 

…the csv looks like this:

Name,ExternalAddress,orgu

Some Person,spersonATjspc.co.uk,brcc.local/BRCC/WsgflAccounts

 

…but then I get this error:

 

A positional parameter cannot be found that accepts argument 'Some Person'.

+ CategoryInfo : InvalidArgument: (:) [New-MailContact], ParameterBindingException

+ FullyQualifiedErrorId : PositionalParameterNotFound,New-MailContact

 

Even adding double quotes to Some Person and the OU position didn't make any difference.

 

I have obviously missed something, but can't, for the life of me, work out what..:-(

Thanks for any tips.....

Posted

Try something like the below

 

 

Import-CSV c:\testimport1.csv | ForEach-Object { New-MailContact -Name $_."DisplayName" -DisplayName $_."DisplayName" -ExternalEmailAddress $_."EmailAddress" -LastName $_."LastName" -FirstName $_."FirstName" -OrganizationalUnit $_."CN=Email,DC=domain,DC=com" }

Posted

Hi sukh,

Thanks for your input, but I'm not sure about your section on the end = '-OrganizationalUnit $_."CN=Email,DC=domain,DC=com" '. Is that the column heading or the format of the column? - the OU where I'd like the contact is 'OU=ContactAccounts,OU=staff,DC=site,DC=com' or the canonicalName is 'site.com/staff/ContactAccounts'. If 'cn' is required of the OU, the properties within 'ADSI edit' are .

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...