Powershell: Import csv into get-mailbox help needed
I have created a script to copy mailboxes from 2007 to 2010. Most of the script is working fine but I have a couple of issues that I just can't seem to crack. First I am trying to import a list of users from CSV and then use set-mailbox to do a variety of things the problem is it always returns, Cannot bind argument to parameter 'Identity' because it is null. here is the exact code. I am just trying this with a simple csv with only one column with usernames in. import-csv users.csv | Set-Mailbox -Identity $_. -EmailAddressPolicyEnabled $false I am also trying to add another SMTP address to all the users from the csv, adding "username@somedomain.com" the somedomain.com will be the same for all users but I would obviously like this to append the different usernames to this. Eventually this will all run in a foreach-object loop if I can figure out what the issue is. I am relatively new to powershell so any help would be greatly appreciated.
March 22nd, 2012 6:34am

When you do an import-csv you'll get an array of custom objects with property names that match the column headings. This doesn't work: import-csv users.csv | Set-Mailbox -Identity $_. because you haven't told it which property of that object ($_) to use for the identity. It needs to be $_.something. What "something" is will depend on what the column heading of your .csv is for the identity reference.[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Free Windows Admin Tool Kit Click here and download it now
March 22nd, 2012 7:48am

Hi, Maybe you could try this: $list = Import-Csv "D:\Scripts\Users.csv" foreach($entry in $list) { $User = $entry.User set-mailbox -id $User -EmailAddressPolicyEnabled $false } Make sure the CSV look like: User User1 User2 User3 Bart Timmermans | Technical Consultant at KPN Consulting Follow me @ My Blog | Linkedin | Twitter Please mark as Answer, if my post answers your Question. Vote as Helpful, if it is helpful to you.
March 22nd, 2012 8:25am

When you do an import-csv you'll get an array of custom objects with property names that match the column headings. This doesn't work: import-csv users.csv | Set-Mailbox -Identity $_. because you haven't told it which property of that object ($_) to use for the identity. It needs to be $_.something. What "something" is will depend on what the column heading of your .csv is for the identity reference.[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Free Windows Admin Tool Kit Click here and download it now
March 22nd, 2012 2:48pm

Hi, Any updates about this topic? Kind regards, Bart TimmermansBart Timmermans | Technical Consultant at KPN Consulting Follow me @ My Blog | Linkedin | Twitter Please mark as Answer, if my post answers your Question. Vote as Helpful, if it is helpful to you.
March 23rd, 2012 12:20pm

This worked perfectly. thanks
Free Windows Admin Tool Kit Click here and download it now
March 23rd, 2012 12:30pm

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

Other recent topics Other recent topics