Whatever you are doing deploying applications, migrating mail server, AD migration, organize an event or conference you need a list of people, some information and maybe a status like the response of an email.

SharePoint is great product to for example manage list and Active Directory is a great directory for example users.

So what do we need to impress our project leader? Yes, a PowerShell synchronization!

First prepare SharePoint with a new site and a custom list except for the automatically added Title column add the following columns: User, FirstName, LastName, LoginName, OldLoginName, Description, PhoneNumber, Email, Sid, Site List. (Add more columns according to your needs)

Columns

Now you are ready to run the script, I used a command similar to this, everything on a single line:

.\Sync-AdToSPList.ps1 http://localhost/ Site1 AfterWork company.corp “LDAP://OU=Users,OU=Malmo,DC=company,DC=corp” “Malmo”

Now wait until it’s done and when you refresh the page in SharePoint you will see all users added, now to a feature!

If you re-run the script you will notice that all users will be updated and not added again! The script is made to found and update according to the SID of the users since this is the only thing that will not change. (Note it will not cleanup disabled or deleted users, that’s a feature to come!)

The script and the SharePoint list is available for download from my Skydrive!

http://cid-8a594dd81f6836a1.skydrive.live.com/embedrowdetail.aspx/Deploy%20Windows/Scripts/SharePoint/Zync-ADtoSPlist.zip

 

Many thanks to my co-worker Niklas from www.powershell.nu!

Advertisements