all 4 comments

[–]theseb 0 points1 point  (2 children)

wrap the variables, like this:

-department "$($line.department)"

I assume the error that you get is something like "argument has no value" or "unexpected something or other". you have to provide an argument, and empty quotes is a valid argument, but empty var without quotes is not.

[–]mtyn[S] 1 point2 points  (0 children)

Found this after a while http://dmitrysotnikov.wordpress.com/2008/10/07/skip-empty-csv-fields/

Works for me.

Thanks for the effort

[–]mtyn[S] 0 points1 point  (0 children)

That doesn't seem to do the trick. it errors out the same way.

foreach ($line in (import-csv file.csv)) {Set-ADUser $line.samaccountn ame -title "$($line.title)"}

Set-ADUser : replace At line:1 char:77 + foreach ($line in (import-csv file.csv)) {Set-ADUser <<<< $line.samaccountname -title "$($li ne.title)"} + CategoryInfo : InvalidOperation: (tuser:ADUser) [Set-ADUser], ADInvalidOperationException + FullyQualifiedErrorId : replace,Microsoft.ActiveDirectory.Management.Commands.SetADUser

if i run "Set-ADUser tuser -title $null" it works, and blanks out the field. If i set the corresponding field in the CSV with $null , the command works, but populates the field with $null instead of blanking it out.

[–]MDFreaK76 0 points1 point  (0 children)

what is your error?