Progressbar is simply achieved in Powershell with Write-progress cmdlet. This cmdlet can be used with below example -
Write-Progress -Activity "File-Copy" -PercentComplete 55 -Status "Something" -Id 1
Running the above command in Powershell prompt is not meaningful, it will not display anything. I saw so many articles about Write-Progess, but all of them are using a dummy example to use Progressbar, so I am presenting an example which will show you a real utilization of Write-progress.
Example of using Write-Progress
The example demonstrates the utilization of Write-Progress. In this example, we will copy files from a source location to a destination and we will display progessbar for this. The status of progressbar will show the status of task. It does not show the file-copy status of individual file, but it shows the percent status of file-copy task as a whole.
I will use SOURCE_PATH and TARGET_PATH variables and if you are testing it on your computer, you must change the path. For god sake, do not use a disk where operating system is installed and do not use a disk which has low disk space. Anyways, a professional will not do such mistake.
Isn't this easy to use Write-Progress in your other scripts!
Enjoy Scripting!
Write-Progress -Activity "File-Copy" -PercentComplete 55 -Status "Something" -Id 1
Running the above command in Powershell prompt is not meaningful, it will not display anything. I saw so many articles about Write-Progess, but all of them are using a dummy example to use Progressbar, so I am presenting an example which will show you a real utilization of Write-progress.
Example of using Write-Progress
The example demonstrates the utilization of Write-Progress. In this example, we will copy files from a source location to a destination and we will display progessbar for this. The status of progressbar will show the status of task. It does not show the file-copy status of individual file, but it shows the percent status of file-copy task as a whole.
I will use SOURCE_PATH and TARGET_PATH variables and if you are testing it on your computer, you must change the path. For god sake, do not use a disk where operating system is installed and do not use a disk which has low disk space. Anyways, a professional will not do such mistake.
Isn't this easy to use Write-Progress in your other scripts!
Enjoy Scripting!
No comments:
Post a Comment