Jump to content

Recommended Posts

Posted

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!

Posted
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)
Posted

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.

Posted
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 :)
Posted

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}
} 

  • Thanks 1
Posted (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 by Michael
  • Thanks 1

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...