This is great! I just substituted the Import-CSV statement - as you suggested & it went beautifully. Thanks so much!
A word to the wise for others who may be in my boat: in my test csv, I accidentally had spaces between the comma and the next smtp address - like this: f...@123.com, smtp:f...@234.com instead of f...@123.com,smtp:f...@234.com Exchange happily created an email address type of smtp (i.e. there's a space before smtp.) THey were listed in a different group on the Email Addresses tab - the <space>smtp mail type. I didn't test if the addresses would work; thankfully this was all dummy accounts that I subsequently deleted. Moral of the story - MBSmith is awesome, and watch for spaces! On Tue, Feb 1, 2011 at 8:45 AM, Michael B. Smith <mich...@smithcons.com> wrote: > No need to manipulate in Excel. There are some slicker ways to do this, but > for something this straightforward, this is easy. > > > > function makeObject( [string]$alias, [string]$proxies ) > > { > > $o = "" | select Alias, ProxyAddresses > > $o.Alias = $alias > > $o.ProxyAddresses = $proxies > > > > $o > > } > > > > $array = @( ( makeObject "fsmith" > "smtp:fsm...@abc.com,smtp:fsm...@xyz.com,smtp:fred.sm...@abc.com" ), > > ( makeObject "tjones" > "smtp:tjo...@abc.com,smtp:tom.jo...@abc.com,smtp:tjo...@xyz.com,smtp:tom.jo...@xyz.com,smtp:t...@123.com" > ) ) > > > > ## $array is equivalent to an import-csv of a file with just those two > fields > > > > foreach( $user in $array ) > > { > > $alias = $user.Alias > > $proxyaddresses = $user.ProxyAddresses.Split( ',' ) > > "$alias has $($proxyaddresses.Count) new proxyaddresses" > > foreach( $proxy in $proxyaddresses ) { "`t$proxy" } > > > > $mailbox = Get-Mailbox $alias -EA 0 > > if( $mailbox ) > > { > > $oldProxy = $mailbox.EMailAddresses > > "`tmailbox has $($oldProxy.Count) old proxy addresses" > > foreach( $proxy in $proxyaddresses ) > > { > > $oldProxy.Add( $proxy ) > > } > > $mailbox | Set-Mailbox -EMailAddresses $oldProxy -EA 0 > > if( $? ) > > { > > "`t...proxy addresses updated" > > } > > else > > { > > "`t...proxy address update failed" > > } > > $mailbox = $null > > } > > else > > { > > "Couldn't get mailbox for $alias" > > } > > } > > > > $array = $null > > > > "...done" > > > > Regards, > > > > Michael B. Smith > > Consultant and Exchange MVP > > http://TheEssentialExchange.com > > > > > > > > The actual table has more columns than this in it, but the data I'm after is > in two columns: > > alias, proxyaddresses > > alias: to -identify the mailbox I'm adding the data from proxyaddresses > column to; > > Proxyaddresses: - a random number of smtp addresses, comma delimited in one > cell. > > > > I can manipulate Excel to get each address in its own cell, if that helps - > then those headings would be from proxyaddress1 to > > proxyaddress7 > > > > (I could even use DN instead of alias, if that's easier) - so the data is > like: > > > > fsmith, smtp:fsm...@abc.com,smtp:fsm...@xyz.com,smtp:fred.sm...@abc.com > > tjones, > smtp:tjo...@abc.com,smtp:tom.jo...@abc.com,smtp:tjo...@xyz.com,smtp:tom.jo...@xyz.com,smtp:t...@123.com > > > > Thanks! - it's kicking my posterior..... > > > > > > On Mon, Jan 31, 2011 at 7:49 PM, Michael B. Smith <mich...@smithcons.com> > wrote: > >> I need to see the data! :-P > >> > >> Regards, > >> > >> Michael B. Smith > >> Consultant and Exchange MVP > >> http://TheEssentialExchange.com > >> > >> > >> -----Original Message----- > >> From: Russ Patterson [mailto:rus...@gmail.com] > >> Sent: Monday, January 31, 2011 7:31 PM > >> To: MS-Exchange Admin Issues > >> Subject: Re: adding proxyAddresses to Exchange 2007 users > >> > >> This is still kicking me while I'm down. > >> > >> Michael, I can see that your logic (the If Then statement) needs to fit in >> my poor attempts somewhere about where the XXX is: > >> > >>>> Import-CSV "C:\data\test.csv" | foreach-object -process { > >>>> Get-mailbox -identity $_.displayname | update-list -property > >>>> emailaddresses XXX -Add > >> >> $_.proxyAddresses | Set-Mailbox} > >> > >> probably using some sort of nested foreach-object thing like: > >> > >> Import-CSV "C:\data\test.csv" | foreach-object -process { Get-mailbox > >> -identity $_.displayname | foreach-object -process { update-list > >> -property emailaddresses <<DO the IF THen .Splitloop here>> -Add > >> magicalproxyArray.elementX.proxyAddresses } | Set-Mailbox} > >> > >> but nothing's working. Can I get one more hint? A BIG one? <G> > >> > >> As always, greatly appreciated. > >> > >> On Mon, Jan 31, 2011 at 5:18 PM, Michael B. Smith <mich...@smithcons.com> >> wrote: > >>> If > >>> $a = "x, y, z" > >>> > >>> Then > >>> > >>> $ary = $a.Split( ',' ) > >>> > >>> Regards, > >>> > >>> Michael B. Smith > >>> Consultant and Exchange MVP > >>> http://TheEssentialExchange.com > >>> > >>> > >>> -----Original Message----- > >>> From: Russ Patterson [mailto:rus...@gmail.com] > >>> Sent: Monday, January 31, 2011 5:16 PM > >>> To: MS-Exchange Admin Issues > >>> Subject: Re: adding proxyAddresses to Exchange 2007 users > >>> > >>> That's true - they are comma delimited in one column. How does one >>> convert those into an array - I tried prepending @( and a ) at the other >>> end; didn't work. > >>> > >>> I posted to both forums because I'm under a time crunch - often MS staff >>> in India respond over night....YOu guys are amazingly prompt - thanks! > >>> > >>> On Mon, Jan 31, 2011 at 5:10 PM, Campbell, Rob >>> <rob_campb...@centraltechnology.net> wrote: > >>>> It sounds like there a comma-separated list of proxy addresses in one >>>> cell that's going to need to be turned into an array of addresses first. > >>>> > >>>> -----Original Message----- > >>>> From: Michael B. Smith [mailto:mich...@smithcons.com] > >>>> Sent: Monday, January 31, 2011 4:05 PM > >>>> To: MS-Exchange Admin Issues > >>>> Subject: RE: adding proxyAddresses to Exchange 2007 users > >>>> > >>>> You reverse the technique shown here: > >>>> > >>>> http://theessentialexchange.com/blogs/michael/archive/2009/07/07/rem > >>>> o v ing-old-emailaddresses-proxyaddresses-in-exchange-2007.aspx > >>>> > >>>> You want $b += $e. > >>>> > >>>> Alternately, $b.Add( $e ). > >>>> > >>>> Regards, > >>>> > >>>> Michael B. Smith > >>>> Consultant and Exchange MVP > >>>> http://TheEssentialExchange.com > >>>> > >>>> > >>>> -----Original Message----- > >>>> From: Russ Patterson [mailto:rus...@gmail.com] > >>>> Sent: Monday, January 31, 2011 5:02 PM > >>>> To: MS-Exchange Admin Issues > >>>> Subject: adding proxyAddresses to Exchange 2007 users > >>>> > >>>> Exchange 2007 SP3. I have a csv of over 500 rows, with displayname and >>>> proxyAddresses in it as the columns. The proxyAddresses column has anywhere >>>> from 3 to 7 smtp: addresses in it, comma delimited. Is there anyway to add >>>> the email addresses to our users? They are all in one OU. > >>>> > >>>> I've been trying hundreds of variations of this: > >>>> > >>>> > >>>> > >>>> Import-CSV "C:\data\test.csv" | foreach-object -process { > >>>> Get-mailbox -identity $_.displayname | update-list -property > >>>> emailaddresses -Add $_.proxyAddresses | Set-Mailbox} > >>>> > >>>> Not having any luck at all. > >>>> > >>>> All help greatly appreciated! > >>>> > >>>> --- > >>>> To manage subscriptions click here: > >>>> http://lyris.sunbelt-software.com/read/my_forums/ > >>>> or send an email to listmana...@lyris.sunbeltsoftware.com > >>>> with the body: unsubscribe exchangelist > >>>> > >>>> --- > >>>> To manage subscriptions click here: > >>>> http://lyris.sunbelt-software.com/read/my_forums/ > >>>> or send an email to listmana...@lyris.sunbeltsoftware.com > >>>> with the body: unsubscribe exchangelist > >>>> > >>>> > >>>> ******************************************************************** > >>>> * > >>>> * > >>>> **************************** > >>>> Note: > >>>> The information contained in this message may be privileged and > >>>> confidential and protected from disclosure. If the reader of this > >>>> message is not the intended recipient, or an employee or agent > >>>> responsible for delivering this message to the intended recipient, > >>>> you are hereby notified that any dissemination, distribution or > >>>> copying of this communication is strictly prohibited. If you have > >>>> received this communication in error, please notify us immediately by >>>> replying to the message and deleting it from your computer. > >>>> ******************************************************************** > >>>> * > >>>> * > >>>> **************************** > >>>> > >>>> > >>>> > >>>> --- > >>>> To manage subscriptions click here: > >>>> http://lyris.sunbelt-software.com/read/my_forums/ > >>>> or send an email to listmana...@lyris.sunbeltsoftware.com > >>>> with the body: unsubscribe exchangelist > >>>> > >>>> > >>> > >>> --- > >>> To manage subscriptions click here: > >>> http://lyris.sunbelt-software.com/read/my_forums/ > >>> or send an email to listmana...@lyris.sunbeltsoftware.com > >>> with the body: unsubscribe exchangelist > >>> > >>> > >>> --- > >>> To manage subscriptions click here: > >>> http://lyris.sunbelt-software.com/read/my_forums/ > >>> or send an email to listmana...@lyris.sunbeltsoftware.com > >>> with the body: unsubscribe exchangelist > >>> > >>> > >> > >> --- > >> To manage subscriptions click here: > >> http://lyris.sunbelt-software.com/read/my_forums/ > >> or send an email to listmana...@lyris.sunbeltsoftware.com > >> with the body: unsubscribe exchangelist > >> > >> > >> --- > >> To manage subscriptions click here: > >> http://lyris.sunbelt-software.com/read/my_forums/ > >> or send an email to listmana...@lyris.sunbeltsoftware.com > >> with the body: unsubscribe exchangelist > >> > >> > > > > --- > > To manage subscriptions click here: > http://lyris.sunbelt-software.com/read/my_forums/ > > or send an email to listmana...@lyris.sunbeltsoftware.com > > with the body: unsubscribe exchangelist > > > > -----Original Message----- > From: Russ Patterson [mailto:rus...@gmail.com] > Sent: Tuesday, February 01, 2011 3:30 AM > To: MS-Exchange Admin Issues > Subject: Re: adding proxyAddresses to Exchange 2007 users > > --- > To manage subscriptions click here: > http://lyris.sunbelt-software.com/read/my_forums/ > or send an email to listmana...@lyris.sunbeltsoftware.com > with the body: unsubscribe exchangelist --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to listmana...@lyris.sunbeltsoftware.com with the body: unsubscribe exchangelist