0
$CSV = Import-Csv -Delimiter "," -Header username,Phone -Path "C:\Tempo\info.csv"
foreach ($username in $CSV) {
    $Temp = "$username.Phone"
    Set-ADuser -Identity $username.Username -Add @{extensionAttribute4="$Temp"}
}

With the CSV file looking like this (one row)

Jakob.User, 6789

When running above Code it adds the following value to the AD object:

@{username=Jakob.User; Phone=6789}.Phone

Instead of what I except, which would be 6789.

Is it something in my code or is more of a "serverfault" (or just how it is excepted to run?)

But if i modify the code so it is Add @{extensionAttribute4="aFineExample"} and then go look at the value, it only adds what i except it to add.

Jakodns
  • 314
  • 1
  • 9
  • I dont see how that is relevant to my issue, My issue is more that when i except it to enter "6789" it enters "@{username=Jakob.User; Phone=6789}.Phone" instead – Jakodns Jul 07 '16 at 14:41
  • 1
    It's relevant in the sense that you are experiencing that exact problem, and the answer(s) there will solve it. You're trying to embed a property of an object in a string and you're doing it incorrectly; which is why your value ends in `.Phone`. – briantist Jul 07 '16 at 14:47
  • Okay, I'll read up on it then. – Jakodns Jul 07 '16 at 14:51
  • @briantist It solved it! Thanks :) – Jakodns Jul 07 '16 at 14:56

0 Answers0