konga-frites
asked on
Exchange 2007 Userdefines Parameters in powershell
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
BenutzerdefiniertesAttribu t1
...
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 $_.BenutzerdefiniertesAttr ibut1 -CustomAttribute2 $_.BenutzerdefiniertesAttr ibut2 -CustomAttribute3 $_.BenutzerdefiniertesAttr ibut3}
With that I always the error:
+ FullyQualifiedErrorId : NamedParameterNotFound,Mic rosoft.Exc hange.Mana gement.Rec ipientTask s.NewMailC ontact
The csv-file looks like this:
Nachname,Vorname,Name,Anze igename,Ex terneEMail Adresse,Al ias,Benutz erdefinier tesAttribu t1,Benutze rdefiniert esAttribut 2,Benutzer definierte sAttribut3
TestNachname,TestVorname,K ES TestNachname TestVorname,KES TestNachname TestVorname,test@test.de,K ESTestNach nameTestVo rname,,KES ,
(of course just one test argument).
Any ideas. I'll appreciate your suggestions :).
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
BenutzerdefiniertesAttribu
...
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 $_.BenutzerdefiniertesAttr
With that I always the error:
+ FullyQualifiedErrorId : NamedParameterNotFound,Mic
The csv-file looks like this:
Nachname,Vorname,Name,Anze
TestNachname,TestVorname,K
(of course just one test argument).
Any ideas. I'll appreciate your suggestions :).
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?
New-MailContact does not have parameter for custom attributes you need to add Set-MailContact for that..
ASKER
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@subsun: I'll try that - should this work (attached File)????
Import-Script-KES-Variante.ps1.txt
Import-Script-KES-Variante.ps1.txt
It should work.. or you can just pipe the New-MailContact output to Set-MailContact as I mentioned in above comment..
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Gah, got ninjaed. Well, what he said.
ASKER
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.
Ok. I'll try later cause on the move right now. Will give you feedback.
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..
$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..
ASKER
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.
No problem, take your time... Have a safe, happy and successful New Year :)
ASKER
@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 $_.BenutzerdefiniertesAttr ibut1
}
the values in the KES-Liste.csv are this
Nachname,Vorname,Name,Anze igename,Ex terneEMail Adresse,Al ias,Organi sationsein heit,Benut zerdefinie rtes 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,KOESa mple_NSamp le_SN,OU_S ample,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/KE S Sample_N Sample_SN' geändert.
Which means something like:
Warning: The command was completed successful, although no settings of 'domain.local/OU_Sample/KE S 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.
@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 $_.BenutzerdefiniertesAttr
}
the values in the KES-Liste.csv are this
Nachname,Vorname,Name,Anze
Sample_N,Sample_SN,KES Sample_N Sample_SN,KES Sample_N Sample_SN,Sample_N@hotmail
With that I get the following hint:
WARNUNG: Der Befehl wurde erfolgreich abgeschlossen, es wurden jedoch keine
Einstellungen von 'domain.local/OU_Sample/KE
Which means something like:
Warning: The command was completed successful, although no settings of 'domain.local/OU_Sample/KE
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.
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"
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"
ASKER
This works fine :) - but as you suggested I'll open another question for that :) - fairness first! of course
Thanks.. You may post the link to the follow-up question here, so that it will be easy for us to find it..
ASKER
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 :).
Hope you guys are satisfied with that :).