Is there a batter way to display progress of Get-ChildItem with Write-Progress

Welcome Forums General PowerShell Q&A Is there a batter way to display progress of Get-ChildItem with Write-Progress

Viewing 2 reply threads
  • Author
    Posts
    • #217851
      Participant
      Topics: 10
      Replies: 11
      Points: 148
      Rank: Participant

      Hello,

      I wrote some code to display progress of running “Get-ChildItem” command but In my opinion it is to big for such simple task.ย  Could it be wrote in simpler way?

      • This topic was modified 9 months, 2 weeks ago by kolaborek08.
    • #217869
      Participant
      Topics: 10
      Replies: 2480
      Points: 6,537
      Helping Hand
      Rank: Community MVP

      I wrote some code to display progress of running “Get-ChildItem” command but In my opinion it is to big for such simple task. Could it be wrote in simpler way?

      Despite of some minor issues and a little bit bad style … I assume it works for you or doesn’t it? ๐Ÿ˜‰

      What’s the actual purpose of this code? Mostly we try to make our code to run as fast as possible. Therefore we wouldn’t use Start-Sleep if it’s not needed. But I assume you included it to actually see the effect of Write-Progress, right? I would write it probably this way:

      I’d recommend to read “The Unofficial PowerShell Best Practices and Style Guide

    • #218112
      Participant
      Topics: 10
      Replies: 11
      Points: 148
      Rank: Participant

      @Olaf –ย Thank you for your reply ๐Ÿ™‚

      Yes, you have right – Start-Sleep was just to see how code is working.

      Code works quite well for my purposes, but I had some feeling that it can be written in the better way ๐Ÿ˜‰

      I’m beginner and I’m trying to improve my skills. Also thx for link to Best Practices. I’ll try to apply to them.

Viewing 2 reply threads
  • The topic ‘Is there a batter way to display progress of Get-ChildItem with Write-Progress’ is closed to new replies.