Guten Morgen,
folgendes Problem:
Ich hab eine csv-Datei, in der Name,Vorname,E-Mail-Adresse,... enthalten sind.
Diese möchte ich unter einem Exchange 2007 64-Bit in die E-Mail-Kontakte miteinfplegen. Ich möchte keine Verteilergruppe und kein neues Postfach.
Ich habe im Internet schon verschiedene Scripts gefunden, jedoch ging keines (trotz umschreiben).
Das "aktuellste" ist:
Add-Content c:\debug.txt "::Starting Import: ";
$err = "";
int $fakecounter = 1;
Import-CSV contacts.csv | ForEach {
$output = "::";
$display = "";
$email = $_."E-mail Address";
$fakecounter++;
if ($_."First Name")
{
$display = $_."First Name";
}
if($_."Middle Name")
{
$display = $display + " " + $_."Middle Name";
}
if($_."Last Name")
{
if ($_."First Name")
{
$display = $display + " " + $_."Last Name";
} else
{
$display = $_."Last Name";
}
}
if($display)
{
} else
{
$display = $_."Company"
}
$output = $output + "Importing: " + $display;
Add-Content c:\debug.txt $output;
$otherfax = $_."Home Fax" + ", " + $_."Other Fax";
$otherphone = $_."Primary Phone" + ", " + $_."Business Phone 2" + ", " + $_."Car Phone" + ", " + $_."Callback" + ", " + $_."Company Main Phone" + ", " + $_."Other Phone";
$otherhome = $_."Home Phone 2" + ", " + "";
$businessstreet = $_."Business Street" + " " + $_."Business Street 2" + " " + $_."Business Street 3";
$postofficebox = $_."Business Address PO Box" + ", " + "";
$initials = $_."Initials";
$notes = $_."Notes";
if($initials.Length -gt 6)
{
$initials = $initials.Substring(0, 6);
}
if($Notes.Length -gt 1022)
{
$notes = $notes.Substring(0, 1022);
}
if($email -like "*@*")
{
New-MailContact -DomainController dc.contoso.com -Name $display -Firstname $_."First Name" -Lastname $_."Last Name" -ExternalEmailAddress $email -OrganizationalUnit "contoso.com/OU/Contacts" -ErrorAction SilentlyContinue -ErrorVariable +err | Set-Contact -DomainController dc.contoso.com -AssistantName $_."Assistant's Name" -City $_."Business City" -Company $_."Company" -Department $_."Department" -DisplayName $display -Fax $_."Business Fax" -HomePhone $_."Home Phone" -Initials $initials -MobilePhone $_."Mobile Phone" -Name $display -Notes $notes -Office $_."Location" -OtherFax $otherfax -OtherHomePhone $otherhome -OtherTelephone $otherphone -Pager $_."Pager" -Phone $_."Business Phone" -PostalCode $_."Business Postal Code" -PostOfficeBox $postofficebox -StateOrProvince $_."Business State" -StreetAddress $businessstreet -TelephoneAssistant $_."Assistant's Phone" -Title $_."Title" -WebPage $_."Web Page" -ErrorAction SilentlyContinue -ErrorVariable +err;
} else
{
$email = "blank" + $($fakecounter) + "@contoso.com";
New-MailContact -DomainController dc.contoso.com -Name $display -Firstname $_."First Name" -Lastname $_."Last Name" -ExternalEmailAddress $email -OrganizationalUnit "contoso.com/OU/Contacts" -ErrorAction SilentlyContinue -ErrorVariable +err | Set-Contact -DomainController dc.contoso.com -AssistantName $_."Assistant's Name" -City $_."Business City" -Company $_."Company" -Department $_."Department" -DisplayName $display -Fax $_."Business Fax" -HomePhone $_."Home Phone" -Initials $initials -MobilePhone $_."Mobile Phone" -Name $display -Notes $notes -Office $_."Location" -OtherFax $otherfax -OtherHomePhone $otherhome -OtherTelephone $otherphone -Pager $_."Pager" -Phone $_."Business Phone" -PostalCode $_."Business Postal Code" -PostOfficeBox $postofficebox -StateOrProvince $_."Business State" -StreetAddress $businessstreet -TelephoneAssistant $_."Assistant's Phone" -Title $_."Title" -WebPage $_."Web Page" -ErrorAction SilentlyContinue -ErrorVariable +err;
}
Set-MailContact -Identity $display -DomainController dc.contoso.com -CustomAttribute15 "Import" -ErrorAction SilentlyContinue -ErrorVariable +err;
}
Add-Content c:\debug.txt $err;
Es kommt immer wieder die gleiche Fehlermeldung:
"Das Argument kann nicht an den Paramter (Name,Identity) gebunden werden, da es NULL ist."
Was heißt das genau? Wie kann ich es ändern??
Ich hoffe auf schnelle und gute Antworten :-))