Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Exchange 2007 Userdefines Parameters in powershell

Posted on 2012-12-21
19
Medium Priority
?
692 Views
Last Modified: 2013-01-08
Hi @all. One more silly question just before Christmas :):
I have an Exchange 2007 installed in German.
I have to import quite a lot of external contacts which should then be member of a dynamic distribution list. The argument for the membership should be a keyword in the user defined parameters (1-15) of the contact.
my problem is, that i don't know the exact expression for the argument in the powershell. i tried the following list:
extensionAttribute1
userdefinedAttribute1
BenutzerdefiniertesAttribut1
...

The powershell command I run is this:
Import-Csv d:\import\KES-Liste1.csv | ForEach {New-MailContact -LastName $_.Nachname -Firstname $_.Vorname -Name $_.Name -DisplayName $_.Anzeigename -ExternalEmailAddress $_.ExterneEMailAdresse -Alias $_.Alias -OrganizationalUnit "pizh.local/KES" -customAttribute1 $_.BenutzerdefiniertesAttribut1 -CustomAttribute2 $_.BenutzerdefiniertesAttribut2 -CustomAttribute3 $_.BenutzerdefiniertesAttribut3}

With that I always the error:
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.Exchange.Management.RecipientTasks.NewMailContact

The csv-file looks like this:
Nachname,Vorname,Name,Anzeigename,ExterneEMailAdresse,Alias,BenutzerdefiniertesAttribut1,BenutzerdefiniertesAttribut2,BenutzerdefiniertesAttribut3
TestNachname,TestVorname,KES TestNachname TestVorname,KES TestNachname TestVorname,test@test.de,KESTestNachnameTestVorname,,KES,
(of course just one test argument).

Any ideas. I'll appreciate your suggestions :).
0
Comment
Question by:konga-frites
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
  • 2
  • +1
19 Comments
 
LVL 16

Expert Comment

by:Rajitha Chimmani
ID: 38712789
From the contents of csv that you posted it looks like there is some mismatch in the last three columns. Can you attach the values in your question in a csv file?
0
 
LVL 40

Expert Comment

by:Subsun
ID: 38712815
New-MailContact does not have parameter for custom attributes you need to add Set-MailContact for that..
0
 

Author Comment

by:konga-frites
ID: 38712830
here you are, 9 field definitions and 9 arguments (the last is emty! -> just a comma)
The problem doesn't seem to be the number of arguments, defined or not, it is the wrong name of the parameter which expresses the user defined attributes in exchange.
KES-Liste1.csv
Import-Script-KES.ps1.txt
0
Are You Ready for GDPR?

With the GDPR deadline set for May 25, 2018, many organizations are ill-prepared due to uncertainty about the criteria for compliance. According to a recent WatchGuard survey, a staggering 37% of respondents don't even know if their organization needs to comply with GDPR. Do you?

 
LVL 40

Accepted Solution

by:
Subsun earned 1040 total points
ID: 38712850
Try somthing like..
Import-Csv d:\import\KES-Liste1.csv | ForEach {New-MailContact -LastName $_.Nachname -Firstname $_.Vorname -Name $_.Name -DisplayName $_.Anzeigename -ExternalEmailAddress $_.ExterneEMailAdresse -Alias $_.Alias -OrganizationalUnit "pizh.local/KES" |
Set-MailContact -customAttribute1 $_.BenutzerdefiniertesAttribut1 -CustomAttribute2 $_.BenutzerdefiniertesAttribut2 -CustomAttribute3 $_.BenutzerdefiniertesAttribut3}

Open in new window

0
 

Author Comment

by:konga-frites
ID: 38712855
@subsun: I'll try that - should this work (attached File)????
Import-Script-KES-Variante.ps1.txt
0
 
LVL 40

Expert Comment

by:Subsun
ID: 38712877
It should work.. or you can just pipe the New-MailContact output to Set-MailContact as I mentioned in above comment..
0
 
LVL 16

Assisted Solution

by:Rajitha Chimmani
Rajitha Chimmani earned 80 total points
ID: 38712884
You can also use your script this way.

Import-Csv d:\import\KES-Liste1.csv | ForEach {New-MailContact -LastName $_.Nachname -Firstname $_.Vorname -Name $_.Name -DisplayName $_.Anzeigename -ExternalEmailAddress $_.ExterneEMailAdresse -Alias $_.Alias -OrganizationalUnit "pizh.local/KES"
Set-MailContact -Identity $_.Anzeigename -CustomAttribute1 $_.BenutzerdefiniertesAttribut1 -CustomAttribute2 $_.BenutzerdefiniertesAttribut2 -CustomAttribute3 $_.BenutzerdefiniertesAttribut3
}

Open in new window

0
 
LVL 12

Assisted Solution

by:GusGallows
GusGallows earned 80 total points
ID: 38712917
The problem you are running into is the customattribute is not a valid parameter for new-mailcontact. You will need to do that piece using the Set-mailcontact. So create your contacts first, then use the set-mailcontact parameter to set the customattribute fields.
0
 
LVL 12

Expert Comment

by:GusGallows
ID: 38712922
Gah, got ninjaed. Well, what he said.
0
 

Author Comment

by:konga-frites
ID: 38713037
So do I get you right: the ps keeps the arguments and the csv in memory until the console is closed?
Ok. I'll try later cause on the move right now. Will give you feedback.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 38713075
If you assign it to a variable then yes.. For example
$temp = Import-Csv d:\import\KES-Liste1.csv
then $Temp will save the information until you close the console or re-assign it. You can also change the scope of variable in PowerShell..
0
 

Author Comment

by:konga-frites
ID: 38721928
Hey guys - thanks for your help. As there are holidays and my family and I are on break till new year. I'll test immediately after back in business. So far - happy new year.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 38721948
No problem, take your time...  Have a safe, happy and successful New Year :)
0
 

Author Comment

by:konga-frites
ID: 38754981
@Subsun: Your Solution worked for this Problem but

@all:
I have now another "problem" with altering existing records.

If I want to change for multiple users one value of a field according the value in an ascii export from another tool.

So the command in the ps I use is this:

Import-Csv d:\import\KES-Liste.csv | ForEach
{
    Set-MailContact -Identity $_.Alias -CustomAttribute1 $_.BenutzerdefiniertesAttribut1
}

the values in the KES-Liste.csv are this
Nachname,Vorname,Name,Anzeigename,ExterneEMailAdresse,Alias,Organisationseinheit,Benutzerdefiniertes Attribut 1,Benutzerdefiniertes Attribut 2,Benutzerdefiniertes Attribut 3
Sample_N,Sample_SN,KES Sample_N Sample_SN,KES Sample_N Sample_SN,Sample_N@hotmail.com,KOESample_NSample_SN,OU_Sample,Unit_1,Unit_2,Unit_3

With that I get the following hint:

WARNUNG: Der Befehl wurde erfolgreich abgeschlossen, es wurden jedoch keine
Einstellungen von 'domain.local/OU_Sample/KES Sample_N Sample_SN' geändert.

Which means something like:
Warning: The command was completed successful, although no settings of  'domain.local/OU_Sample/KES Sample_N Sample_SN' were changed.

No more hints from the ps why nothing was changed. The values in the csv are definitely different to them in the AD.

Some more hints????

Tanks a lot in advance.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 38755023
If this is a different problem then I would suggest you to open another question for it.. ;-)

BTB.. What if you run the command manually for one user? before running the command check the users attribute and make sure it's not same..
Set-MailContact -Identity KOESample_NSample_SN -CustomAttribute1 "Unit_1"
0
 

Author Comment

by:konga-frites
ID: 38755113
This works fine :) - but as you suggested I'll open another question for that :) - fairness first! of course
0
 
LVL 40

Expert Comment

by:Subsun
ID: 38755148
Thanks.. You may post the link to the follow-up question here, so that it will be easy for us to find it..
0
 

Author Closing Comment

by:konga-frites
ID: 38755162
as subsun was the first he deserved the lion's share. but there were also Rajitha14 and GusGallows who had the same problem-solving approach.this should also be rewarded :).

Hope you guys are satisfied with that :).
0

Featured Post

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
Are you an Exchange administrator employed with an organization? And, have you encountered a corrupt Exchange database due to which you are not able to open its EDB file. This article will explain all the steps to repair corrupt Exchange database.
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question