Editing extensionattribute15 on a user with Powershell

We used to run Exchange (2003) internally, but no longer do. However we wanted to add a value to a user, where the user, and the value, were included in a CSV file. So if you want to add/modify a users extensionattribute with Powershell, this is how you can do it!


#Variables - edit as required
################################################################
$server = "gregdom.int"
$csvfile = "emea to groupid.csv"
################################################################

$userstrings = Import-Csv $csvfile

Foreach ($userstring in $userstrings) {
	$Username = $userstring.Username
	$Value = $userstring.ValuetoAdd

	$DN = (Get-adUser $username -Server $server).DistinguishedName
 	$User = [ADSI]"LDAP://$DN"
 	$User.Put("extensionAttribute15", $value)
 	$User.SetInfo()	
				
	}

Advertisements

Leave a comment

Filed under Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s