none
Command to set AcceptMessagesOnlyFrom on Distribution Groups from a CSV file RRS feed

  • Question

  • Hi All,

    I tried the previous thread scripts but none working to apply for the permissions from the CSV format below

    I'm trying to set the  AcceptMessagesOnlyFrom from a CSV file generated by the script below

    "DisplayName","Name"
    "JHRPS - All","T22KWT5"
    "CID_SIR","francisco_diaz"
    "CID_SIR","T22KWT5"
    "CID_SIR","thomas_matthewjr"

    Here DisplayName is the DL Name and Name is Just Name attribute, not the User <g class="gr_ gr_433 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="433" id="433">Displayname</g>

    $csv = Import-Csv "C:\Scripts\Reports\DG_Owners_Report.csv"
    $csv.AcceptMessagesOnlyFrom += (Get-DistributionGroup $_.DisplayName)
    $csv | Set-DistributionGroup -AcceptMessagesOnlyFrom $csv.Name

    The property 'AcceptMessagesOnlyFrom' cannot be found on this object. Verify that the property exists and can be set.

    At C:\scripts\ApplyPermissions.ps1:6 char:1
    + $csv.AcceptMessagesOnlyFrom += (Get-DistributionGroup $_.DisplayName)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : PropertyAssignmentException

    The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input
        + CategoryInfo          : InvalidArgument: (@{DisplayName=JHRPS - All; Name=T22KWT5}:PSObject) [Set-DistributionGroup], ParameterBindingException
        + FullyQualifiedErrorId : InputObjectNotBound,Set-DistributionGroup
        + PSComputerName        : nym-exco365-cj.ntlab.life.com

    The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input
        + CategoryInfo          : InvalidArgument: (@{DisplayName=C...ewyorklife.com}:PSObject) [Set-DistributionGroup], ParameterBindingException
        + FullyQualifiedErrorId : InputObjectNotBound,Set-DistributionGroup
        + PSComputerName        : nym-exco365-cj.ntlab.life.com

    The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input
        + CategoryInfo          : InvalidArgument: (@{DisplayName=CID_SIR; Name=T22KWT5}:PSObject) [Set-DistributionGroup], ParameterBindingException
        + FullyQualifiedErrorId : InputObjectNotBound,Set-DistributionGroup
        + PSComputerName        : nym-exco365-cj.ntlab.life.com

    The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input
        + CategoryInfo          : InvalidArgument: (@{DisplayName=C...ewyorklife.com}:PSObject) [Set-DistributionGroup], ParameterBindingException
        + FullyQualifiedErrorId : InputObjectNotBound,Set-DistributionGroup
        + PSComputerName        : nym-exco365-cj.ntlab.life.com

    Cannot process argument transformation on parameter 'Identity'. Cannot convert the "System.Collections.ArrayList" value of type "System.Collections.ArrayList" to type
    "Microsoft.Exchange.Configuration.Tasks.DistributionGroupIdParameter".
        + CategoryInfo          : InvalidData: (:) [Get-DistributionGroup], ParameterBindin...mationException
        + FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-DistributionGroup
        + PSComputerName        : nym-exco365-cj.ntlab.life.com

    Can some please help to correct the above script.

    Thanks in Advance.


    Hari Cherepally


    Monday, August 27, 2018 3:42 PM

Answers

  • Hi Hari 

    The problem looks to be how you are tyring to get the info from the csv file. You could try the below, also when adding to acceptedmessageonlyfrom it will be over writen each time if you dont use an add hash table. You could try the below and see if that works for you. 

    $csv = Import-Csv "C:\Scripts\Reports\DG_Owners_Report.csv"
    foreach ($DG in $csv){
    Set-DistributionGroup -Identity $DG.DisplayName -AcceptMessagesOnlyFrom @{Add=$DG.Name}
    }


    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.

    Monday, August 27, 2018 6:39 PM

All replies

  • Hi Hari 

    The problem looks to be how you are tyring to get the info from the csv file. You could try the below, also when adding to acceptedmessageonlyfrom it will be over writen each time if you dont use an add hash table. You could try the below and see if that works for you. 

    $csv = Import-Csv "C:\Scripts\Reports\DG_Owners_Report.csv"
    foreach ($DG in $csv){
    Set-DistributionGroup -Identity $DG.DisplayName -AcceptMessagesOnlyFrom @{Add=$DG.Name}
    }


    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.

    Monday, August 27, 2018 6:39 PM
  • Thanks Sir. That worked awesome.

    I tried modifying the script in the same format earlier but i don't know that did not work either maybe i was missing somewhere. 

    Thanks once again.

    Hari

     

    Hari Cherepally

    Monday, August 27, 2018 8:02 PM