Quantcast
Channel: Directory Services forum
Viewing all articles
Browse latest Browse all 31638

Add New Attributed Field in Active Directory 2008

$
0
0

Dears,

Recently we decided add new director field in AD attributed field in windows server 2008, I'm following below link to created the attributed

http://www.showmehowtodoit.com/create-custom-active-directory-attributes-for-user-properties/

and I'm using below script to import users but it is not working, even the script working when I add the same user in default attributed which is already exist  in AD, kindly your advice.

Import-ModuleActiveDirectory

$path=Split-Path-parent$MyInvocation.MyCommand.Definition

# ENSURE THAT IMPORT FILE IS IN THE SAME DIRECTORY AS THIS SCRIPT

#

$importfile=$path+"\sample.csv"

$logfile=$path+"\logfile.txt"

#

# DO NOT EDIT AFTER THIS LINE

FunctionImportUsers

{

Import-CSV$importfile|ForEach-Object{

$sam=$_.Users.ToLower()

$manager=$_.Manager

$output="User:"+$sam

Try{

If($manager) {

Try{$exists=Get-ADUser-LDAPFilter"(sAMAccountName=$manager)"}

Catch{ }

If($exists) {

Get-ADUser-Identity$sam|Set-ADUser-Manager$_.Manager

}

}

$output+" updated successfully"|Out-File$logfile-append

}

Catch{

$output+" update failed: "+$error[0].ToString()|Out-File$logfile-append

}

}

}

ImportUsers


Viewing all articles
Browse latest Browse all 31638

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>