Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

i have the script as

5..12 | foreach-object { import-csv "\\servername\staffdata\IT\Login Accounts\2011\AD\Year$_.csv" } | ForEach-Object { Enable-Mailbox $_.email -Database "Student Mailbox Store" }

and i have a csv named Year5_2.csv in the correct folder. I am getting the following error

Import-Csv : Cannot open file "\servername\staffdata\IT\Login Accounts\2011\AD\Year5.csv". At line:1 char:36

Any suggestions please

share|improve this question

closed as not a real question by Evan Anderson, Sam, Sven, Iain, sysadmin1138 Jan 21 '11 at 23:47

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
disregard i was using the wrong file. –  JohnyV Jan 21 '11 at 7:19

1 Answer 1

If the file name is Year5_2.csv than you should use syntax similar to: Import-Csv "\servername\staffdata\IT\Login Accounts\2011\AD\Year$_`_2.csv"

$_ = 5..12 if 2 is also variable than you need to tweak it a bit. HTH Bartek

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.