diff --git a/snippets/PowerShell.json b/snippets/PowerShell.json index e5b23be643..9371047850 100644 --- a/snippets/PowerShell.json +++ b/snippets/PowerShell.json @@ -165,8 +165,9 @@ "prefix": "foreach-progress", "description": "Insert a foreach loop with Write-Progress initialized", "body": [ - "\\$progPercent = \"{0:n2}\" -f ([math]::round(\\$i/\\$array.count,4) * 100)", - "Write-Progress -Activity \"${3:activityName}\" -Status \"\\$i of \\$array.count - \\$progPercent% Complete:\" -PercentComplete \\$progPercent", + "\\$total = \\$${1:array}.count", + "\\$progPercent = \"{0:n2}\" -f ([math]::round(\\$i/\\$total,4) * 100)", + "Write-Progress -Activity \"${3:activityName}\" -Status \"\\$i of \\$total - \\$progPercent% Complete:\" -PercentComplete \\$progPercent", "\\$i = 1", "foreach ($${2:item} in $${1:array}) {", " \\$progPercent = \"{0:n2}\" -f ([math]::round(\\$i/\\$total,4) * 100)", @@ -670,4 +671,4 @@ "}" ] } -} +} \ No newline at end of file