viernes, 3 de noviembre de 2017

WINDOWS. PS. Easy uptade user attributes.

I explain a simple and quicly script to update user AD attributes. At this example update 3 atributes from AD users

[ ] Source txt tributes:

LOCATION_NAME , COMPANY_NAME, LOCATION_ADDRESS


Source user data: C:\tmp\Upgradeusersdata\users.csv

[ ] Destination AD atributes

Office, Company, StreetAddress




[ ] Script:


/***********************************************************************/
# Import AD Module
Import-Module ActiveDirectory

$Delimiter = ";"

write-Host 'Starting to update AD Attributes.......' -NoNewline -ForegroundColor Yellow
# Import CSV into variable $LIST_users

$LIST_users = Import-Csv C:\tmp\Upgradeusersdata\users.csv $Delimiter
# Loop through CSV and update users if the exist in CVS file

$LIST_users|Foreach{

Set-ADUSer -Identity $_.Login -Office $_.LOCATION_NAME -Company $_.COMPANY_NAME -StreetAddress $_.LOCATION_ADDRESS
Write $_.Login

}

Write-Host 'done!' -ForegroundColor Green


/***********************************************************************/

The "-Identity" will be our index.

Check at Windows 2012 R2
by GoN | Published: November 3, 2017 | Last Updated:

No hay comentarios: