Importer contacts uden e-mail address policy
Beklager hvis det er en lidt lang forklaring.Jeg skal importere en raekke contacts fra Exchange 2003 til Exchange 2007. Vi har valgt at ikke at benytte public folders, saa vi 0nsker i stedet at oprette disse objekter som contacts i A.D.
Jeg benytter nedenstaaende script til at importere disse contacts fra en .pst fil, dette virker fint.
Mit problem er at den default e-mail policy i Exchange automatisk tildeler de nyoprettede contacts en default e-mail, (name@company.com). Jeg kan disable dette direkte paa contact objectet men saa er skaden jo sket med den tildelte email addresse.
Er der nogen som har en smartere maade at g0re dette her paa?
SCRIPT:
Add-Content d:\temp\debug.txt "::Starting Import: ";
$err = "";
Import-Csv contacts.csv | ForEach {
$output = "::";
$display = "";
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";
}
}
$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" + ", " + "";
New-MailContact -DomainController ADOMAINCONTOLLER.internal -Name $display -Firstname $_."First Name" -Lastname $_."Last Name" -ExternalEmailAddress $_."E-mail Address" -OrganizationalUnit "ADOMAIN.internal/Contacts" -ErrorAction SilentlyContinue -ErrorVariable +err | Set-Contact -DomainController ADOMAINCONTOLLER.internal -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 ADOMAINCONTOLLER.internal -CustomAttribute15 "" -ErrorAction SilentlyContinue -ErrorVariable +err;
}
Add-Content c:\debug.txt $err;