Zum Inhalt springen

Empfohlene Beiträge

Geschrieben

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 :-))

Geschrieben

/// EDIT ///

Guten Morgen,

es hat sich eine Kleinigkeit geändert.

In meiner Liste habe ich nur noch "Name" und "E-Mail Adresse" und, das Script lautet nur noch:

Import-Csv NAME.csv | ForEach { New-MailContact -Name $_.Anzeigename -ExternalEmailAdress $_.EMailAddresse }

Trotzdem kommt weiterhin die Fehlermeldung, dass das Argument nicht an den Parameter zurückgegeben werden kann, da der Wert NULL ist.

Könnt ihr mir helfen?

Erstelle ein Benutzerkonto oder melde Dich an, um zu kommentieren

Du musst ein Benutzerkonto haben, um einen Kommentar verfassen zu können

Benutzerkonto erstellen

Neues Benutzerkonto für unsere Community erstellen. Es ist einfach!

Neues Benutzerkonto erstellen

Anmelden

Du hast bereits ein Benutzerkonto? Melde Dich hier an.

Jetzt anmelden

Fachinformatiker.de, 2024 by SE Internet Services

fidelogo_small.png

Schicke uns eine Nachricht!

Fachinformatiker.de ist die größte IT-Community
rund um Ausbildung, Job, Weiterbildung für IT-Fachkräfte.

Fachinformatiker.de App

Download on the App Store
Get it on Google Play

Kontakt

Hier werben?
Oder sende eine E-Mail an

Social media u. feeds

Jobboard für Fachinformatiker und IT-Fachkräfte

×
×
  • Neu erstellen...