Scripting error with Bulk GAL updates
I am importing a CSV to bulk update user accounts in the GAL and even though the script appears to be correct (and it actually works) it produces an error. I haven't tried this on the CSV with my hundred or so users yet, just on a couple of test accounts, and as I said it produces the desired results. but since it is throwing an error I would like to understand and hopefully resolve it before I throw the full list at it.CSV looks like this:Identity,STAFFFIRSTNAME,STAFFLASTNAME,DEPARTMENT,TITLE,Office,MobilePhone,PhoneJohn Doe,John,Doe,Technology,Systems Administrator,South,999-9999,1105Test,Test,,Department of Testing,Head Guinea Pig,North,,1101The command I am using to run it looks like this:Import-CSV “C:\GalUpdates.csv” | ForEach-Object –Process {Set-User –Identity $_.Identity –Department $_.Department –Title $_.Title –Office $_.Office –MobilePhone $_.MobilePhone –Phone $_.Phone}There are some fields like stafffirstname and stafflastname that are only there because they were on the excel spreadsheet used to create the CSV, they are not used in the script. I have tried cleaning up the CSV just to eleminate the extra variables but it made no difference. The error I keep receiving is this:Set-User : Cannot bind parameter 'Identity'. Cannot convert value "" to type "Microsoft.Exchange.Configuration.Tasks.UserIdParameter". Error: "The parameter value of this type Microsoft.Exchange.Configuration.Tasks.UserIdParameter cannot be empty.Parameter name: identity"At line:1 char:77+ Import-CSV "C:\GalUpdates.csv" | ForEach-Object -Process {Set-User -Identity <<<< $_.Identity -Department $_.Department -Title $_.Title -Office $_.Office -MobilePhone $_.MobilePhone -Phone $_.Phone}What I have tried is various ways of altering the information in the identity field on the CSV including with quotes and even going so far as to put the full identity as in MyDomain.local/users/test and MyDomain.local/users/John Doe but this had no effect. Meaning it still works but still throws the same error.
February 25th, 2010 2:34am

Step through it.Import-CSV “C:\GalUpdates.csv” | ForEach-Object –Process {$_ | fl}no errors?
Free Windows Admin Tool Kit Click here and download it now
February 25th, 2010 2:40am

Is it possible that one or more items in the CSV do not have a value in the identity column?
February 25th, 2010 2:42am

Hi,Please verify if there's no value on identity. Form the error it said Cannot convert value "" to type "Microsoft.Exchange.Configuration.Tasks.UserIdParameter". Regards, Xiu
Free Windows Admin Tool Kit Click here and download it now
February 25th, 2010 9:18am

Well the answer came to me last night and I read these posts above before I tested it and you all are on the right track. The error does suggest that it sees a blank identity field somewhere and yet I knew none of the lines had a blank identity field. But what was also puzzling was that it worked. It modified every account I wanted modified in exactly the way I wanted. I didn't run the command you suggested mjoliner because I didn't need to but I have no doubt it would have revealed the problem was at the very end of the CSV; it had to be because it worked. So last night I thought, what if there is a blank line in the CSV? And so there was. I had generated the CSV from the spreadsheet and then modified it for testing purposes by cutting and pasting and typing in a line for the account named test. Somehow I left a couple carriage returns at the very end. So as the command processed each line, it succeeded on all of them as expected until it got to the end and found a blank line or two and then it errored out.
February 25th, 2010 7:34pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics