Reading, modifying and deleting attributes of Active Directory Objects with Powershell

March 31, 2009 09:23 by hiho

I just thought i'd do a quick one on Powershell, and how it can be used to modify Active Directory attributes, especially regarding multi-valued ones. In this example, i'm using the [ADSI] accelerator for direct access to AD. I'm also utilizing the .putex method, for more granular control. For more information on .putex, please see http://support.microsoft.com/kb/260251.

And there you go....

------------------------------------------------------------------------------

#Scripting example of using PS and [ADSI] accelerator to modify AD attributes
#This example reads, modifies and deletes all the values in the "proxyaddresses"-attribute of an user object.
#
#USE THIS CODE AT YOUR OWN RISK. DO PROPER LAB TESTS. NO WARRANTIES IMPLIED. LEGAL BLAH.
#(c) 2009, Georg Hinterhofer

#Clear Screen
cls

#Dim array to hold multi-valued attributes
[array] $proxy

#Set LDAP path
$LDAPPath ="LDAP://CN=test,CN=Users,DC=forest1,DC=local"
$ADUser = [ADSI]"$LDAPPath"

#Read multi-valued properties
$proxy = $aduser.proxyAddresses

#Delete a multi-valued properties
$ADUser.putex(1,"proxyAddresses",$null)
$ADUser.setinfo()

#Set a multi-valued property
[Array] $newProxy = "SMTP:test@microsoft.at","smtp:test2@test.at"
$ADUser.putex(2,"proxyAddresses",$newProxy)
$ADUser.setinfo()

#Add a property to multi-valued
[array] $smtpToAdd = "smtp:test3@test.at"
$ADUser.putex(3,"proxyAddresses",$smtpToAdd)
$ADUser.setinfo()

#Remove a property from multi-valued
[array]$smtpToRemove = "smtp:test2@test.at"
$ADUser.putex(4,"proxyAddresses",$smtpToRemove)
$ADUser.setinfo()

------------------------------------------------------------------------------

So enjoy this one,

Regards,

Georg


Currently rated 5.0 by 3 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Passed MS Certs 70-647,70-649 and 70-620

August 29, 2008 12:11 by hiho

Well, i usually don't like bragging, but here goes... i've successfully completed the above mentioned exams (each > 950 points). As i also own the MCSA/MCSE Credentials for 2000/2003, i'am proud to announce that i have completed all necessary exams to be recognized as a

Microsoft Certified IT-Professional: Enterprise Administrator

As of now, i hold the following Microsoft Credentials: MCP, MCSA 2000/2003, MCSA+M,MCSE 2000/2003,MC:TS,MCITP:EA

I would like to thank everyone who made this possible, especially my employer, iT-Austria.

If you would like to learn more about Microsoft Certifications, i suggest you visit Microsoft Certification Overview.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Blogging: First Blog, First Post

August 6, 2008 16:00 by hiho

... not a Hello World - Post, but nearly.

I'dl like to introduce myself: my name's George, better known under the nickname "hiho". i'am an exchange adminstrator for a large Austrian it-company, responsible for Exchange core-services and Blackberry for aprrox 12000 mailboxes. As a second, i run my own business, hihosoft.at, to provide services to small and medium-sized customers.

As i frequently research other blogs for troubleshooting suggestions, hints, etc. i thought i would be nice to do something similar. I will try to post everyday solutions here, as well as posts concerning my other hobbies - flying, music, sports, pinball, computers and programming.

This blog runs on BlogEngine.net, which i'd like to highly recommend - it runs on IIS/ASP.Net and can utilize either .xml-files or sql-servers as backend storage. it is very easy to set up and implement, and is customizable with themes.

So long,

hiho


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5