0

I am trying to populate the attribute ExtensionAttribute7 with a CSV file. The CSV file has two columns: samAccountName and ExtensionAttribute7

I import the Active Directory module and have been trying this script:

Import-Csv C:\sam-eid.csv | ForEach-Object {
Set-ADUser $_.samAccountName -Replace @{ExtensionAttribute7=$._ExtensionAttribute7}} 

This is the error return I am getting:

$._ExtensionAttribute7 : The term '$._ExtensionAttribute7' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:2 char:62 + ... mAccountName -Replace @{ExtensionAttribute7= $._ExtensionAttribute7}} + ~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: ($._ExtensionAttribute7:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

Any ideas? I've tried -Add instead of -Replace to no avail.

1

Try the following:

Import-Csv C:\sam-eid.csv | ForEach-Object {
  Set-ADUser $_.samAccountName -Replace @{ExtensionAttribute7=$_.ExtensionAttribute7} } 

You may have a syntax issue $._ versus $_.

  • for some weird reason, the _ is not showing in the answer, even though it is there Import-Csv C:\sam-eid.csv | ForEach-Object { Set-ADUser $_.samAccountName -Replace @{ExtensionAttribute7=$_.ExtensionAttribute7}} – Lex Feb 18 '16 at 23:04
  • Have a look at serverfault.com/help/formatting – jscott Feb 18 '16 at 23:09
  • The syntax was the issue. One of those situations where a fresh set of eyes makes all the difference in the world. Thank you! – Jim Feb 19 '16 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.