Trouble with adjusting multivalued property
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?
July 16th, 2011 7:19pm

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 " "
Free Windows Admin Tool Kit Click here and download it now
July 16th, 2011 8:14pm

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"
July 17th, 2011 2:16pm

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...
Free Windows Admin Tool Kit Click here and download it now
July 17th, 2011 2:38pm

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
July 17th, 2011 8:41pm

Thanks. I will try that sometime - concentrating on some non-Exchange prbs right now.
Free Windows Admin Tool Kit Click here and download it now
July 19th, 2011 1:11pm

Hi Le Pivert, Any update for your issue? Regards! Gavin
July 24th, 2011 10:29am

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.
Free Windows Admin Tool Kit Click here and download it now
August 13th, 2011 5:07pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics