Link to home
Start Free TrialLog in
Avatar of whorsfall
whorsfallFlag for Australia

asked on

Powershell - Show progress with import-csv

Hi,

Is there any way when importing a CSV file via powershel (import-csv) l i can display the progress via the
write-progress cmdlet.

Thanks,

Ward
Avatar of tolinrome
tolinrome
Flag of United States of America image

Does this help?
http://mrhodes.net/category/powershell/

About halfway down the page under the heading "Adding 285 Contoso Users with Pictures to your Development Environment Active Directory"
Avatar of whorsfall

ASKER

Hi,

Thanks for that. Um not really this code give progress after the csv has been imported. I am after during.

Thanks,

Ward
Avatar of footech
There's no real way to display progress for this.  You could display something like which line number it is on, but to display something like a percent complete, you need to know what the end point is, and you don't know that until you've read in the entire file, so it's a chicken and the egg problem.  Here's an example of displaying the line number.
Import-CSV file.csv | % -begin {$i=0} -process { Write-Progress -activity "Importing file" -currentOperation "Reading line $i" -PercentComplete -1; $i++ }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial