Hope someone will help. Newbie to this Forum, apologies if I offend. I have exported an list of user sAMAccountnames from AD domain and forest level 2008 r2.
I have extended the schema to add a new attribute called barcode.
I need to take a .csv with each user and their new barcode number and add it to the attribute "barcode".
I'm using a .csv file with a test users in it to get the Script right, the file is named adtest.csv
I'm using the Administrator:Active Directory module for Windows Powershell
I'm using a sample script as a basis from here:"http://itknowledgeexchange.techtarget.com/powershell/bulk-modifications-using-set-aduser/"
# Import CSV into variable $userscsv$users=Import-Csv-PathC:\Scripts\adtest.csv# Loop through CSV and update users if the exist in CVS fileforeach($userin$users){#Search in specified OU and Update existing attributesGet-ADUser-Filter"SamAccountName -eq '$($user.samaccountname)'"-Properties*-SearchBase"cn=Students,cn=Users,DC=OURDOMAIN,DC=LOCAL"|Set-ADUser-Replace@{l="$($user.barcode)"}}
I'm getting this Error:Get-ADUser : Directory object not found
At line:3 char:2
+ Get-ADUser -Filter "SamAccountName -eq '$($user.samaccountname)'"
-Properties * ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
+ CategoryInfo : ObjectNotFound: (:) [Get-ADUser], ADIdentityNotF
oundException
+ FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.
Management.ADIdentityNotFoundException,Microsoft.ActiveDirectory.Managemen
t.Commands.GetADUser