Powershell - Show progress with import-csv

Posted on 2014-08-05
Last Modified: 2014-09-02

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


Question by:whorsfall
    LVL 7

    Expert Comment

    Does this help?

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

    Author Comment


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


    LVL 38

    Expert Comment

    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

    LVL 67

    Accepted Solution

    Using Import-CSV with a pipe, like
    import-csv file.csv | % { <# processing code #> }

    Open in new window

    should get rid of the need for a progress indicator. The import is done row by row, and the current row is processed immediately. Usually the processing takes more time than the import, and hence is the more interesting and time consuming part. In this scenario, a progress indicator could be shown for the loop part, and we are back to http:#a40241044.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    How to sign a powershell script so you can prevent tampering, and only allow users to run authorised Powershell scripts
    "Migrate" an SMTP relay receive connector to a new server using info from an old server.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now