Link to home
Start Free TrialLog in
Avatar of James Danahay
James DanahayFlag for Australia

asked on

Add proxy settings to AD via Powershell

I need to add a second smtp address to the proxy addresses in the attribute editor for 1100 users in AD. I wish to do this by selecting a .csv file via powershell. The problem is I'm not sure of the command and I'm also not sure what data in required in the.csv for this to work.
ASKER CERTIFIED SOLUTION
Avatar of Mahesh
Mahesh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Can very easily be done with powershell.  

This can be done without extra tools, but it's much harder..
I'd start with the Quest (now part of Dell) ActiveRoles Management Shell for Active Directory 1.7 https://support.software.dell.com/download-install-detail/5024645

So.. assuming you have that, and assume your CSV file is set up like this:
AccountName,NewMailAddress

Be sure you include the header row.
import-module -name quest*

$csv = import-module -path c:\temp\users.csv

$csv | foreach-object {

$user = get-qaduser -identity $_.AccountName -includedProperties proxyAddresses
set-qaduser -objectAttributes { proxyAddresses=@{Append=@("smtp:$user.NewMailAddress")}}

$user = $null
$mail = $null
}

Open in new window


That should pretty much do it. For reference, look at Shay Levy's article - http://blogs.microsoft.co.il/scriptfanatic/2010/02/04/modifying-multivalued-active-directory-attributes/

Worst case, you might have to tweak it a bit.  but the basics should be good :-)

Coralon
Avatar of James Danahay

ASKER

Hi - If I type just Import-module it asks for a name0 ,1, 2 etc  - what does the name represent? What should the module name be?
You just literally type it in as is.. but don't forget the asterisk.

import-module -name quest*

That will import all modules that start with quest.

Coralon