locked
Trouble with adjusting multivalued property RRS feed

  • Question

  • It looks so easy here:

    http://technet.microsoft.com/en-us/library/bb684908(EXCHG.80).aspx

    Of course, when I try to do it (for something else, granted), it doesn't work:

    [PS] C:\>$DDG = Get-DynamicDistributionGroup | where {$_.Name -like "*class*"}
    [PS] C:\>$DDG

    Name                           
    ----                  
    #Class of 2011
    #Class of 2012
    #Class of 2013
    #Class of 2014
    #Class of 2015


    [PS] C:\>$DDG.AcceptMessagesOnlyFrom += "John Doe"
    Property 'AcceptMessagesOnlyFrom' cannot be found on this object [...]

    This is how I thought I'd find the proper value:

    [PS] C:\>Get-DynamicDistributionGroup "#Class of 2011" | fl *accept*

    AcceptMessagesOnlyFrom   [snip]

    How do I find all the correct properties of the DynamicDistributionGroup object?

    [PS] C:\>Get-DynamicDistributionGroup | get-member -type property

    [snip]

    Name              

    ----                              

    AcceptMessagesOnlyFrom

    Well... it looks like that IS the correct property to use.

    So why isn't this working?


    Saturday, July 16, 2011 11:08 PM

Answers

  • In the meantime (I'd still like to figure this one out), I was able to get what I wanted like this:

    [PS] C:\>$Senders = ("John Doe", "Jane Doe", "Ellen Smith", "Ernie Smith")
    [PS] C:\>Set-DynamicDistributionGroup "#Class of 2011" -AcceptMessagesOnlyFrom $Senders

    I just arrow up and down, tab as needed, and change class years. It works...

    • Marked as answer by Gavin-Zhang Saturday, July 30, 2011 7:36 AM
    Sunday, July 17, 2011 6:34 PM
  • On Sun, 17 Jul 2011 18:12:40 +0000, Le Pivert wrote:
     
    >
    >
    >Thanks. I suspected it had something to do with arrays... and that you would know the answer.
    >
    >Unfortuntately, I'm getting this error message (was sure it was going to work however!):
    >
    >[PS] C:\>$DDG | foreach-object {$_.AcceptMessagesOnlyFrom += "John Doe"}
    >
    >Exception setting "AcceptMessagesOnlyFrom": "Cannot convert value "System.Object[]" to type "Microsoft.Exchange.Data.MultiValuedProperty`1[Microsoft.Exchange.Data.Directory.ADObjectId]". Error: "Failed to convert John Doe from System.String to Microsoft.Exchange.Data.Directory.ADObjectId."" At line:1 char:27
    >
    >It's not the array either, because I tried with a single group and get the same error.
    >
    >Tried with the email address as well: "jdoe@contoso.com"
     
    When you use the set-dynamicdistributiongroup you can use one of these
    as the data part of the -AcceptMessagesOnlyFrom parameter:
    * Distinguished name (DN)
    * Canonical name
    * GUID
    * Name
    * Display name
    * Alias
    * Exchange DN
    * Primary SMTP e-mail address
     
    When you're scripting you can't use a string where some other object
    type is required.
     
    Try this:
    $DDG | foreach {$_.AcceptMessagesOnlyFrom += (get-recipient "John Doe"
    -resultsize 1)}
     
    ---
    Rich Matheisen
    MCSE+I, Exchange MVP
     

    --- Rich Matheisen MCSE+I, Exchange MVP
    • Marked as answer by Gavin-Zhang Saturday, July 30, 2011 7:36 AM
    Monday, July 18, 2011 12:37 AM

All replies

  • Remember that $DDG is an array of dynamicdistributiongroup objects.  The individual dynamicdistributiongroup objects have an AcceptMessagesOnlyFrom property, but the array itself does not. 

    $DDG | foreach-object {$_.AcceptMessagesOnlyFrom += "John Doe"}


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    Sunday, July 17, 2011 12:02 AM
  • Thanks. I suspected it had something to do with arrays... and that you would know the answer.

    Unfortuntately, I'm getting this error message (was sure it was going to work however!):

    [PS] C:\>$DDG | foreach-object {$_.AcceptMessagesOnlyFrom += "John Doe"}


    Exception setting "AcceptMessagesOnlyFrom": "Cannot convert value "System.Object[]" to type "Microsoft.Exchange.Data.MultiValuedProperty`1[Microsoft.Exchange.Data.Directory.ADObjectId]". Error: "Failed to convert John Doe from System.String to Microsoft.Exchange.Data.Directory.ADObjectId.""
    At line:1 char:27

    It's not the array either, because I tried with a single group and get the same error.

    Tried with the email address as well: "jdoe@contoso.com"

    Sunday, July 17, 2011 6:12 PM
  • In the meantime (I'd still like to figure this one out), I was able to get what I wanted like this:

    [PS] C:\>$Senders = ("John Doe", "Jane Doe", "Ellen Smith", "Ernie Smith")
    [PS] C:\>Set-DynamicDistributionGroup "#Class of 2011" -AcceptMessagesOnlyFrom $Senders

    I just arrow up and down, tab as needed, and change class years. It works...

    • Marked as answer by Gavin-Zhang Saturday, July 30, 2011 7:36 AM
    Sunday, July 17, 2011 6:34 PM
  • On Sun, 17 Jul 2011 18:12:40 +0000, Le Pivert wrote:
     
    >
    >
    >Thanks. I suspected it had something to do with arrays... and that you would know the answer.
    >
    >Unfortuntately, I'm getting this error message (was sure it was going to work however!):
    >
    >[PS] C:\>$DDG | foreach-object {$_.AcceptMessagesOnlyFrom += "John Doe"}
    >
    >Exception setting "AcceptMessagesOnlyFrom": "Cannot convert value "System.Object[]" to type "Microsoft.Exchange.Data.MultiValuedProperty`1[Microsoft.Exchange.Data.Directory.ADObjectId]". Error: "Failed to convert John Doe from System.String to Microsoft.Exchange.Data.Directory.ADObjectId."" At line:1 char:27
    >
    >It's not the array either, because I tried with a single group and get the same error.
    >
    >Tried with the email address as well: "jdoe@contoso.com"
     
    When you use the set-dynamicdistributiongroup you can use one of these
    as the data part of the -AcceptMessagesOnlyFrom parameter:
    * Distinguished name (DN)
    * Canonical name
    * GUID
    * Name
    * Display name
    * Alias
    * Exchange DN
    * Primary SMTP e-mail address
     
    When you're scripting you can't use a string where some other object
    type is required.
     
    Try this:
    $DDG | foreach {$_.AcceptMessagesOnlyFrom += (get-recipient "John Doe"
    -resultsize 1)}
     
    ---
    Rich Matheisen
    MCSE+I, Exchange MVP
     

    --- Rich Matheisen MCSE+I, Exchange MVP
    • Marked as answer by Gavin-Zhang Saturday, July 30, 2011 7:36 AM
    Monday, July 18, 2011 12:37 AM
  • Thanks. I will try that sometime - concentrating on some non-Exchange prbs right now.

    Tuesday, July 19, 2011 5:07 PM
  • Hi Le Pivert,


    Any update for your issue?

    Regards!
    Gavin
    Sunday, July 24, 2011 2:25 PM
  • I honestly did not get a chance to look at this (and had solved the problem otherwise) but I'd be willing to bet Rich's solution works so I'm sure it deserves to be marked as the answer.
    Friday, August 5, 2011 8:55 PM