Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Mail Contact with PS, Company and Department Attributes Error

Status
Not open for further replies.

ncotton

IS-IT--Management
Jan 27, 2006
2,841
GB
Hi all,
I'm looking for some help with a PS script I'm using to import users from CSV.

Code:
Import-Csv "C:\PSScripts\MailContact.csv" | ForEach-Object { New-MailContact -Name $_.Name -ExternalEmailAddress $_.Email -FirstName $_.FirstName -LastName $_.LastName -Company $_.Company -Department $_.Department -OrganizationalUnit "domain/Contacts" -Alias $_.Alias }

The script works fine if I remote the company and department aspects.

I get the error
PowerShell Error said:
A positional parameter cannot be found that accepts argument '-Company'.
+ CategoryInfo : InvalidArgument: :)) [New-MailContact], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,New-MailContact

The breakdown of the CSV is fine.

When I try and add the details manually, then Get-MailContact, I still don't see any parameters for company, department, job title etc. This must be possible somehow.

Please help, it's driving me mad.

Much appreciated.
Neil
 
Those properties are for aduser, not mailbox, so you'd want to fire an additional procedure after the mailbox creation to add those attributes to the aduser. You'll see them if you do a get-aduser | fl

Dave Shackelford
ThirdTier.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top