none
Try to create distributiongroups & Mailcontacts: Argument is null? RRS feed

  • Question

  • Hello Everybody

    Nothing works for me and i can't figure out why.

    I have powershell with the exchange-modules imported, started as admin, on The exchange-mailbox-server.

    First my code to create the Mailcontacts:

    Import-CSV "C:\temp\TestMailContactsToDo.csv" | Foreach {
    New-MailContact -ExternalEmailAddress $_.mail -Name $_.name -FirstName $_.fname -LastName $_.lname -OrganizationalUnit "*oupath*"
    }

    Csv:

    name;lname;fname;mail

    Anton Taler;Taler;Anton;anton.taler@example.com

    Marie-Louise Sabine;Marie-Louise;Sabine;sabine.MarieLouise@example.com

    Error:

    New-MailContact : Cannot bind argument to parameter 'ExternalEmailAddress' because it is null.
    At line:2 char:38
    + New-MailContact -ExternalEmailAddress <<<<  $_.mail -Name $_.name -FirstName $_.fname -LastName $_.lname -Organizatio
    nalUnit "*oupath*"
        + CategoryInfo          : InvalidData: (:) [New-MailContact], ParameterBindingValidationException
        + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.Exchange.Management.RecipientTa
       sks.NewMailContact

    Code for creating the Distribution-Groups:

    Import-CSV "C:\temp\GroupNamesToDo.csv" | foreach {
    New-DistributionGroup -Name $_.name -DisplayName $_.dname -Alias ToLower($_.alias) -Type "Distribution" -OrganizationalUnit "*oupath*" -ManagedBy "ILZ\AL67" -MemberDepartrestriction "Closed" -MemberJoinRestriction "Closed"
    }

    Csv:

    name;dname;alias

    Groupone;Groupone;*sub-OU*-groupone

    Groupexample Fish;Groupexample Fish;Fish-Groupexample.Fish

    Error:

    New-DistributionGroup : Cannot bind argument to parameter 'Name' because it is null.
    At line:2 char:28
    + New-DistributionGroup -Name <<<<  $_.name -DisplayName $_.dname -Alias ToLower($_.alias) -Type "Distribution" -Organi
    zationalUnit "*oupath*" -ManagedBy "ILZ\AL67" -MemberDepartrestriction "Closed" -MemberJo
    inRestriction "Closed"
        + CategoryInfo          : InvalidData: (:) [New-DistributionGroup], ParameterBindingValidationException
        + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.Exchange.Management.RecipientTa
       sks.NewDistributionGroup

    Thanks if anyone can give me an idea what's wrong!


    Friday, July 1, 2016 6:48 AM

Answers

All replies