Skip to content

Commit

Permalink
Fixed issue #6 - Divide by zero error
Browse files Browse the repository at this point in the history
Fixed an issue where the correct device count wasn't being established.
This should work properly, now.
  • Loading branch information
scottdware committed Aug 28, 2014
1 parent 9c5a272 commit 1351db6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Posh-Junos.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function Invoke-JunosConfig {
$config = Get-Content (Resolve-Path $ConfigFile)
$devices = Import-CSV (Resolve-Path $DeviceList)
$headers = $devices[0].PSObject.Properties | Select-Object Name
$totalDevices = $devices.Count
$totalDevices = $devices | Measure-Object
$current = 0
$errors = 0

Expand All @@ -112,7 +112,7 @@ function Invoke-JunosConfig {
New-Item -Path $logfile -ItemType file | Out-Null
}

Write-Output "`nStarting configuration on a total of $totalDevices devices."
Write-Output "`nStarting configuration on a total of $($totalDevices.Count) devices."
Write-Output "Results will be logged to '$logfile'`n"

foreach ($row in $devices) {
Expand All @@ -128,8 +128,8 @@ function Invoke-JunosConfig {
}

$creds = Get-Auth -User $user -Password $pass
$percent = [Math]::Round($current / $totalDevices * 100)
Write-Progress -Activity 'Configuration in progress...' -Status "$current of $totalDevices devices ($percent%):" -PercentComplete $percent
$percent = [Math]::Round($current / $totalDevices.Count * 100)
Write-Progress -Activity 'Configuration in progress...' -Status "$current of $($totalDevices.Count) devices ($percent%):" -PercentComplete $percent

Log-Output -File $logfile -Content "[$(Timestamp)] Starting configuration on $Device..."

Expand Down

0 comments on commit 1351db6

Please sign in to comment.