How to write progress bars with PowerShell

Поділитися
Вставка
  • Опубліковано 1 гру 2024

КОМЕНТАРІ • 22

  • @PetterTech
    @PetterTech  2 роки тому

    This video is somewhat based on a blog post I did ages ago. So if you prefer a written piece on this topic you can find it here: pettertech.com/2014/01/powershell-write-progress-a-step-by-step-guide/

  • @TheRealJohnMadden
    @TheRealJohnMadden 2 роки тому +3

    Awesome video! I'm trying to learn PowerShell for my job to automate some mundane tasks in our IT department, this will make it look like I know what I'm doing xD Cheers!!

  • @GoingMod
    @GoingMod 3 роки тому +2

    Thanks, trying to write progress for backing up the reg for reg changes. This helps a lot!

  • @jonathanlapar2849
    @jonathanlapar2849 2 роки тому

    Awesome job!! I added the child progress bar to one of my loops and it worked like a charm!

    • @PetterTech
      @PetterTech  2 роки тому

      Fantastic! Glad you found a use for this!

  • @Lil_mar00
    @Lil_mar00 Рік тому

    broooooo, you just elevated my game. Thank you!

  • @jonathanwitherspoon32
    @jonathanwitherspoon32 2 роки тому

    This was so helpful. I am trying to use this in a script now. Also thanks for the Git link.

    • @PetterTech
      @PetterTech  2 роки тому

      Really glad it was helpful :)

  • @nevorchi
    @nevorchi 5 місяців тому

    Thank you sir, I appreciate this!

  • @realNAKAMI
    @realNAKAMI 2 роки тому

    looking for a way to also have the progress display in the taskbar and it seems that it's not trivial...

    • @PetterTech
      @PetterTech  2 роки тому

      Agreed. Had to look it up myself and currently there doesn't seem to be any easy way to do this yet. Hopefully there will be eventually, but I suspect that this is such a niche usecase that it will not be prioritized by Microsoft

  • @Andreasftw11
    @Andreasftw11 3 роки тому

    This content is splendid

  • @blackholechennai
    @blackholechennai 3 роки тому

    How to see progress for big file copy for the below line
    Copy-item c:\test1 -Destination c:\test2 -Recurse

    • @PetterTech
      @PetterTech  3 роки тому

      If it's one big file then write-progress can't really help you.
      But if it's a lot of files then you can start by getting the full list of files and then throw that into a foreach loop which then writes progress AND copies the files.
      Consider this example:
      $AllFiles = Get-ChildItem C:\test1 -Recurse
      $progress = 1
      foreach ($SingelFile in $AllFiles) {
      Write-Progress -Activity "Copying files" -Status "Working on $($SingelFile)" -PercentComplete ($progress/$AllFiles.count*100)
      Copy-Item -Path $SingelFile.FullName -Destination "c:\test2\$($SingelFile.FullName.substring(9))"
      $Progress++
      }

    • @PetterTech
      @PetterTech  3 роки тому

      The destination part might be a little obscure there but basically what it does is set the destination to c:\test2\ followed by whatever the path was before (minus the first 9 characters, in this case c:\test1\)

    • @blackholechennai
      @blackholechennai 3 роки тому

      @@PetterTech thanks for quick help. That make scene 😉.

  • @jamesrumsey7241
    @jamesrumsey7241 2 роки тому +1

    Dude get a drink of water