Change contact email address from CSV
Change contact email address from CSV

Active Directory Quest Cmdlets are required : available here

This script require a csv file (change.csv) that use the following template:
contact-distinguishedname ; mailaddress

The script read the csv file and change the email addresses of the contacts

Script :

$contactlist = gc "C:\temp\change.csv"
foreach($line in $contactlist) {
	$dn = $line.split(";")[0]
	$mail = $line.split(";")[1]
	Set-QADObject $dn -ObjectAttributes @{mail=$mail ; targetAddress="SMTP:$mail"}
}

<>

My Powershell script categories


Reference

Set-QADObject

Modify attributes of an object in Active Directory. Supported are both Active Directory Domain Services (AD DS) and Active Directory Lightweight Directory Services (AD LDS).

This cmdlet is part of the Quest ActiveRoles Server product. Use Get-QARSProductInfo to view information about ActiveRoles Server.

Syntax
Set-QADObject [-Identity] <IdentityParameter> [-Connection <ArsConnection>] [-ConnectionAccount <string>] [-ConnectionPassword <SecureString>] [-Control <hashtable>] [-Credential <PSCredential>] [-Description <string>] [-DeserializeValues] [-DisplayName <string>] [-ExcludedProperties <string[]>] [-IncludedProperties <string[]>] [-ObjectAttributes <ObjectAttributesParameter>] [-Proxy] [-Service <string>] [-UseDefaultExcludedProperties <Boolean>] [-UseGlobalCatalog] [-Confirm] [-WhatIf] [<CommonParameters>]
Detailed Description

Use this cmdlet to change or remove values of attributes of an object in Active Directory.

The cmdlet has optional parameters that determine the server and the security context for the operation. Normally, the connection parameters could be omitted so far as a connection to a server is established prior to using the cmdlet. In this case, the server and the security context are determined by the Connect-QADService cmdlet.

If you do not use Connect-QADService and have no connection established prior to using a cmdlet, then the connection settings, including the server and the security context, are determined by the connection parameters of the first cmdlet you use. Subsequent cmdlets will use those settings by default.

Parameters
Name Description Required? Pipeline Input Default Value
Connection For parameter description, see help on the Connect-QADService cmdlet. false false
ConnectionAccount For parameter description, see help on the Connect-QADService cmdlet. false false
ConnectionPassword For parameter description, see help on the Connect-QADService cmdlet. false false
Control Use this parameter to pass request controls (in-controls) to ActiveRoles Server as part of an operation request. In ActiveRoles Server, request controls are used to send extra information along with an operation request, to control how ActiveRoles Server performs the request.The parameter value is a hash table that defines the names and values of the request controls to be passed to ActiveRoles Server. The parameter syntax is as follows:

   -Control @{ = ; [ = ] ...}

In this syntax, each of the name-value pairs is the name and the value of a single control. For instructions on how to create and use hash tables, see topic “about_associative_array” or “about_hash_tables” in Windows PowerShell Help. For information about ActiveRoles Server request controls, refer to ActiveRoles Server SDK documentation.

Note that this parameter only has an effect on the operations that are performed through ActiveRoles Server (connection established using the Proxy parameter); otherwise, this parameter causes an error condition in ActiveRoles Management Shell.

false false
Credential For parameter description, see help on the Connect-QADService cmdlet. false false
Description Set or clear the ‘description’ attribute. false false
DeserializeValues Supply this parameter on the command line if the input you pass to the cmdlet contains serialized attribute values (for instance, when importing a directory object from a text file that was created using the Serialize parameter). For examples of how to export and import an object, see help on the Get-QADUser cmdlet. false false
DisplayName Set or clear the ‘displayName’ attribute. false false
ExcludedProperties Use this parameter to specify the attributes that you do not want the cmdlet to update in the directory. Supply a list of the attribute LDAP display names as the parameter value. You could use this parameter when importing attribute values from a text file, in order to prevent some attributes found in the file from being set in the directory. false false
Identity Specify the DN, SID, GUID, UPN or Domain\Name of the object whose attributes you want to modify. This parameter is optional since you can pipe into this cmdlet the object returned by a Get-QADObject cmdlet, to have that object identify the object to act upon. true true (ByValue)
IncludedProperties Use this parameter to specify explicitly the attributes that you want the cmdlet to update in the directory. Supply a list of the attribute LDAP display names as the parameter value. When used together with UseDefaultExcludedProperties, this parameter allows you to have the cmdlet update some attributes that would not be updated otherwise.Note: If a particular attribute is listed in both ExcludedProperties and IncludedProperties, the cmdlet does not set the value of that attribute the directory. false false
ObjectAttributes Specify an associative array that defines the attributes to set. The array syntax:@{attr1=’val1′;attr2=’val2′;…}

In this syntax, each of the key-value pairs is the LDAP display name and the value of an attribute to set. Thus, passing the @{title=’Associate’;l=’Paris’} array to the ObjectAttributes parameter causes the cmdlet to set the ‘Job Title’ attribute to ‘Associate’ and the ‘City’ attribute to ‘Paris’.

For information about associative arrays, type the following command at the PowerShell command-prompt:

help about_associative_array

false true (ByValue, ByPropertyName)
Proxy For parameter description, see help on the Connect-QADService cmdlet. false false
Service For parameter description, see help on the Connect-QADService cmdlet. false false
UseDefaultExcludedProperties When set to ‘true’, this parameter causes the cmdlet not to update a certain pre-defined set of attributes in the directory. This pre-defined set of attributes (referred to as “default excluded properties”) can be viewed or modified by using the Get-QADPSSnapinSettings or Set-QADPSSnapinSettings cmdlet, respectively. false false
UseGlobalCatalog For parameter description, see help on the Connect-QADService cmdlet. false false
Confirm Prompts you for confirmation before executing the command. false false
WhatIf Describes what would happen if you executed the command without actually executing the command. false false

 

Examples
EXAMPLE 1
set-QADObject 'CN=John Smith,OU=CompanyOU,DC=company,DC=com' -description 'Sales person'

Description


Connect to any available domain controller with the credentials of the locally logged on user, bind to a specific object by DN, and modify the description of the object.

 

EXAMPLE 2
$pw = read-host "Enter password" -AsSecureString

C:\PS>connect-QADService -service 'server.company.com' -ConnectionAccount 'company\administrator' -ConnectionPassword $pw

C:\PS>set-QADObject -identity 'S-1-5-21-1279736177-1630491018-182859109-1305' -description 'Service account'

C:\PS>disconnect-QADService

Description


Connect to a specific domain controller with the credentials of a specific user, bind to a certain object by SID, modify the description of the object, and then disconnect.

 

EXAMPLE 3
$pw = read-host "Enter password" -AsSecureString

C:\PS>connect-QADService -service 'localhost' -proxy -ConnectionAccount 'company\administrator' -ConnectionPassword $pw

C:\PS>set-QADObject -identity 'company\associates' -ObjectAttributes @{info='';description='All company associates'}

C:\PS>disconnect-QADService

Description


Connect to the local Administration Service with the credentials of a specific user, bind to a certain object by Domain\Name, set or clear certain attributes, and then disconnect.

 

EXAMPLE 4
set-QADObject '' -Service 'server.domain.local:389' -description 'My AD LDS object'

Description


Connect to the AD LDS instance on ‘server.domain.local:389’ with the credentials of the locally logged on user, bind to a specific AD LDS object by DN, and modify the description of the object.

Change contact email address from CSV

Leave a Reply

Your email address will not be published.