locked
PLEASE HELP: Creating a New Mail Contact without a default email address being assigned RRS feed

  • Question

  • I am currently in the process of creating a site that will automate a lot of the processes that we do here where I work and in the middle of creating something that would be a proof a concept for our people here to say ok that looks like a viable idea I have ran into something that is extremely frustrating and I have not found one discussion that even touches my issue. I just want to know how to create one contact in Active Directory without a default domain SMTP email address being assigned to it. I have seen the whole "change the -EmailAddressPolicy to the $false Boolean" for Set-Mailcontact but that does not solve the problem. I want to keep it from ever even creating it in the first place. Also, if you say "Well why don't you go in there and modify your script to remove the address afterwards with -EmailAddresses @{Remove=*@whatever.co}" I have already thought of that and even ran the script from the prompt to see what it would do and it does nothing it just says "Warning: The command completed successfully but no settings of 'Test Contact' have been modified." If I can figure out how to create just one contact without this hiccup It will be smooth sailing. Any help would be appreciated thank you.
    • Moved by Bill_Stewart Friday, November 28, 2014 5:01 PM Abandoned
    Wednesday, October 1, 2014 8:20 PM

Answers

  • I don't think you can do that.

     Exchange maintains an internal directory of all mail enabled objects, indexed by their email addresses.  Mail enabled objects without an email address will break that indexing.


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

    • Proposed as answer by jrv Wednesday, October 1, 2014 10:10 PM
    • Marked as answer by Just Karl Tuesday, December 23, 2014 10:04 PM
    Wednesday, October 1, 2014 8:34 PM

All replies

  • Hi,

    How are you creating the contact in the first place? Try New-ADObject (see the last example):

    http://ss64.com/ps/new-adobject.html


    Don't retire TechNet! - (Don't give up yet - 13,085+ strong and growing)

    Wednesday, October 1, 2014 8:26 PM
  • Here is the current script I am using assume that the parameters have been loaded into the script.

    New-MailContact -ExternalEmailAddress SMTP:$email -Name $name -Alias $first$last -FirstName $first -Initials $initials -LastName $last -OrganizationalUnit $location
    Set-Contact -identity $email -Phone $phone -Department $company

    Wednesday, October 1, 2014 8:29 PM
  • Not that it matters but so the $name part doesn't make you tilt your head to the side.

    $name = ($first + ' ' + $last)

    New-MailContact -ExternalEmailAddress $email -Name $name -Alias $first$last -FirstName $first -Initials $initials -LastName $last -OrganizationalUnit $location
    Set-Contact -identity $email -Phone "$phone" -Department $company
    rm "E:\credfiles\$username2.txt"

    Wednesday, October 1, 2014 8:33 PM
  • I don't think you can do that.

     Exchange maintains an internal directory of all mail enabled objects, indexed by their email addresses.  Mail enabled objects without an email address will break that indexing.


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

    • Proposed as answer by jrv Wednesday, October 1, 2014 10:10 PM
    • Marked as answer by Just Karl Tuesday, December 23, 2014 10:04 PM
    Wednesday, October 1, 2014 8:34 PM
  • The rm part is for a credential file that I create and then remove at the end of the script so don't pay attention to that I didn't mean to put that in there.
    Wednesday, October 1, 2014 8:34 PM
  • I'd skip the Exchange cmdlets and try New-ADObject. I don't have a test enviroment available at the moment.

    Don't retire TechNet! - (Don't give up yet - 13,085+ strong and growing)

    Wednesday, October 1, 2014 8:41 PM
  • I'd skip the Exchange cmdlets and try New-ADObject. I don't have a test enviroment available at the moment.

    Don't retire TechNet! - (Don't give up yet - 13,085+ strong and growing)

    A MailUser object is basically a mail-enabled user object that has both an internal and external email address.  All email addressed to the internal address will be automatically routed to the external address.

    If you want to create the object in advance without mail enabling it, then New-ADUser probably be more appropriate.


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

    Wednesday, October 1, 2014 8:48 PM
  • I have tried that but because the script is ran by the administrator account on the server the php web page is hosted on it rejects that account from using import-module ActiveDirectory and as you know if that module isn't loaded powershell does not recognize that command. Also, the contacts have to be mail-enabled to be seen in our Office 365 environment. They won't even show up in the GAL if they are not mail-enabled. If someone could give me a suggestion of how I could somehow manipulate the script to allow import-module ActiveDirectory for that administrator account and mail-enable the contact afterwards maybe that could be the solution I am looking for.
    Thursday, October 2, 2014 12:54 PM
  • Would it work if you used a constrained, delegated remoting session that has the AD module already loaded and have the script use that via invoke-command?  



    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

    Thursday, October 2, 2014 1:25 PM
  • That could be a possibility. We need to create a service account to execute some of the DA level commands we will need it to run anyways so I could definitely try it. I will let you know how it goes. IF anyone else has a suggestion also please let me know. I find combined ideas are the best as a whole.
    Thursday, October 2, 2014 8:14 PM