Thursday, May 16, 2013

Copy Attribute Values–PowerShell Script

This can be used to copy a value from one attribute to another.  In the below example, I am coping Exchange Alias (mailnickname) value to extensionattribute14


# Author - Santhosh Sivarajan
# Version 1.0
$N = 0
$UserInfoFile = New-Item -type file -force "D:\Scripts\UserInfo.txt"
"distinguishedName`tAlias" | Out-File $UserInfoFile -encoding ASCII
$ObjFilter = "(&(objectCategory=person)(objectCategory=User)(mail=*)(!extensionAttribute14=*))"
$objSearch = New-Object System.DirectoryServices.DirectorySearcher
$objSearch.PageSize = 15000
$objSearch.Filter = $ObjFilter 
$objSearch.SearchRoot = "LDAP://DC=sivarajan,DC=com"
$AllObj = $objSearch.FindAll()
    foreach ($Obj in $AllObj)
        $user = [ADSI] $Obj.path
        $objItemT = $Obj.Properties
        $tAlias = $objItemT.mailnickname
        $tUDN =  $objItemT.distinguishedname
        Write-host -NoNewLine "Updating.... $tUDN"
        "$tUDN`t$tAlias" | Out-File $UserInfoFile -encoding ASCII -append
        Write-host "Done!"
        $N ++   

Write-host "Successfully updated $N user obejcts.  Please reveiw $UserInfoFile for more information"


I will learn more about this script. I might use it in the future. Bye!

Lots of interesting information on this site I always visit him. If you are a student you will find many interesting things there. I showed it to all my friends.

Best Assignment Help Online has been a frequent provider of online services in the US and other countries for more than five years. Help Me Do My Homework

Hyvää päivänjatkoa, rakkaat ystävät. Jos sinulla on ongelmia sukupuolielinten kanssa, - neuvoisin sinua aloittamaan lääkityksen viagra netistä, - joka varmasti auttaa sinua, aivan kuten minäkin!

Post a Comment

Popular Posts


Twitter Delicious Facebook Digg Stumbleupon Favorites More