Skip to content

Commit 995039e

Browse files
ian-morJustinGrote
andauthored
Update total handling in foreach-progress snip
Co-authored-by: Justin Grote <[email protected]>
1 parent 7222ba6 commit 995039e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

snippets/PowerShell.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@
165165
"prefix": "foreach-progress",
166166
"description": "Insert a foreach loop with Write-Progress initialized",
167167
"body": [
168-
"\\$total = $${1:array}.count",
168+
\\$progPercent = \"{0:n2}\" -f ([math]::round(\\$i/\\$array.count,4) * 100)",
169+
170+
Write-Progress -Activity \"${3:activityName}\" -Status \"\\$i of \\$array.count - \\$progPercent% Complete:\" -PercentComplete \\$progPercent",
169171
"\\$i = 1",
170172
"Foreach ($${2:item} in $${1:array}) {",
171173
" \\$progPercent = \"{0:n2}\" -f ([math]::round(\\$i/\\$total,4) * 100)",

0 commit comments

Comments
 (0)