Michael Posted May 3, 2016 Posted May 3, 2016 Hello all, I've recently setup a new O365 Tenancy and deployed AADSync only for account creation and password sync (so far so good). The site in question do not have an on premises Exchange server, so I need to populate the ProxyAddresses attribute. I'm using the following Powershell script: $users=import-csv C:\input.csv foreach($user in $users){ $u = Get-ADUser $user.name -Properties mail,department,ProxyAddresses $u.ProxyAddresses = $user.ProxyAddress Set-ADUser -instance $u } This works, however each SMTP entry needs to be on a separate line. SMTP (in capitals) is Primary, and smtp thereafter are configured as aliases. If I configure [email protected]; [email protected]; etc... it doesn't work as intended. Each entry needs to be on a separate line, but how can I do this from Excel? Many thanks!
mb2k01 Posted May 3, 2016 Posted May 3, 2016 I know it doesn't answer the specific question you asked, but I've used ADModify to do this previously. You can do it using the username switch (which I think is %samAccountName% but don't quote me! @school.onmicrosoft.com and then do another run to add in @school.lea.sch.uk. (Actually... got to the end of writing this and aren't too sure it was ADModify I used.. it might have been WiseSoft BulkModify, but both are pretty similar)
Michael Posted May 3, 2016 Author Posted May 3, 2016 I've used ADModify before, but unfortunately it also can only do one entry at a time (as far as I can tell). E-mail Addresses (tab), then entering: %'SamAccountName'%@domain.com works, but as I say, you can only specify one address. Essentially my PowerShell script does the same. The frustrating thing is AD itself lists them as SMTP:[email protected]; smtp:[email protected]; smtp:[email protected] but you can't import strings/lines separated with ; from a CSV file. They import, but all as one line.
mb2k01 Posted May 3, 2016 Posted May 3, 2016 I see what you mean. For me, it didn't matter as I just ran ADModify the three times I needed it (1 for smtp:[email protected], 2 for smtp:[email protected] 3 for SMTP:[email protected]). Wasn't a huge issue as only took a couple of minutes to do my 1000 users. I guess if you're wanting to engineer a neat run-once solution then that isn't any good. 1
Michael Posted May 3, 2016 Author Posted May 3, 2016 Ahh brilliant, OK that works - as you say, you have to do it in stages. The Powershell script just overwrites all entries, whereas AdModify does exactly that - modifies, unless you wish to remove. I think this will have to be it
Matt_Renato Posted May 3, 2016 Posted May 3, 2016 This should work if you have the proxy addresses in a single column in you CSV separated by a semi-colon Import-CSV "C:\Scripts\Proxy.csv" | ForEach-Object { $name = $_.user $proxy = $_.proxyaddresses -split ';' Set-AdUser -Identity $name -Add @{proxyaddresses = $proxy} } 1
Michael Posted May 4, 2016 Author Posted May 4, 2016 (edited) Unfortunately the above doesn't work, but this code I edited does: $users=import-csv C:\input.csv foreach($user in $users){ $u = Get-ADUser $user.name -Properties mail,department,ProxyAddresses $u.ProxyAddresses = $user.ProxyAddress -split ';' Set-ADUser -instance $u } PAUSE Create the CSV file as (no spaces between the smtp entries): CAPS SMTP for Primary address only. Name,ProxyAddress user1,SMTP:[email protected];smtp:[email protected];smtp:[email protected];smtp:[email protected] Also if you're wondering how I get around the multiple domain issue e.g: domain1.com domain2.com and domain3.com etc.. - navigate to Active Directory Domains and Trusts, right click Active Directory Domains and Trusts and select 'Properties'. The UPN Suffixes window appears. Add your required domains here: domain1.com domain2.com domain3.com Now return back to Active Directory, open the properties of a user and navigate to the 'Account' tab. You can now change the UPN suffix from the drop down list, changing it from your local Domain name. This'll then match it as required when using AADSync. If you don't do this, users will end up with a .onmicrosoft.com domain by default. Hope this helps someone else Edited May 4, 2016 by Michael 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now