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.

Jim
  • 17
  • 3
  • 6

1 Answers1

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 $_.

jscott
  • 24,204
  • 8
  • 77
  • 99
Lex
  • 564
  • 1
  • 6
  • 16
  • 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 http://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