Are you sure that there's a column named "samAccountName" in the CSV file's header record?
Run this to verify the column is named the way you say it is:
[array]$x = Import-csv "c:\scripts\sf\beauty.csv"
if ($x[0].psobject.properties.name -notcontains "samAccountName"){
write-host "samAccountName isn't a column in the CSV!" -ForegroundColor Red
return
}
Assuming that it doesn't say the column name is missing, perhaps there are empty lines in the CSV? Try adding some simple data verification to the script:
Import-csv "c:\scripts\sf\beauty.csv" |
ForEach-Object{
if ($_.samAccountName.Trim().Length -gt 1){
Get-ADUser -Identity ($_.samAccountName.Trim()) |
Set-ADUser -Add @{SalesforceRole="Beauty"}
}
}
Note that you're trying to add a property name "SalesforceRole", not an extension attribute., to the user object. Is that what you want? Have you extended the AD schema to include that attribute?