Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
jorioux committed Apr 20, 2018
1 parent 73f2bc1 commit 68a0a01
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion Functions/ConvertTo-Array.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ Function ConvertTo-Array {
$Size = $ArrLine[$_]/1KB/1KB
$Item | Add-Member -type NoteProperty -Name $Headers[$_].replace(' [kB]',' (GB)') -Value $Size
} elseif($Headers[$_] -match '^.*\[MB/min\]') {
$Item | Add-Member -type NoteProperty -Name $Headers[$_].replace(' [MB/min]',' (MB/min)') -Value $ArrLine[$_]
$Value = ConvertTo-Int $ArrLine[$_]
$Item | Add-Member -type NoteProperty -Name $Headers[$_].replace(' [MB/min]',' (MB/min)') -Value $Value
} elseif($Headers[$_] -match '(GB Written|Media|Errors|Warnings|Objects|Files)') {
$Value = ConvertTo-Int $ArrLine[$_]
$Item | Add-Member -type NoteProperty -Name $Headers[$_].replace(' [MB/min]',' (MB/min)') -Value $Value
} else {
$Item | Add-Member -type NoteProperty -Name $Headers[$_] -Value $ArrLine[$_]
}
Expand All @@ -95,4 +99,31 @@ Function ConvertTo-Array {
END {
return $ArrayOutput
}
}

Function ConvertTo-Int {
<#
.SYNOPSIS
Converts a string value to a Int or Double
#>
[CmdletBinding()]
Param(
[Parameter(ValueFromPipeline = $true)]
[ValidateNotNullOrEmpty()]
$IntVal
)
try{
if($IntVal.GetType().FullName -match '^.*Int.*$') {
return [int]$IntVal
} elseif($IntVal.GetType().FullName -match '^.*(Double|Float).*$') {
return [math]::Round([double]$IntVal,2)
} elseif($IntVal -match '^.*(\,|\.).*$') {
return [math]::Round([double]($IntVal.replace(',','.')),2)
} else {
return [int]($IntVal)
}
} catch {
write-host "catch"
return $IntVal
}
}
Binary file modified PowerDP.psd1
Binary file not shown.

0 comments on commit 68a0a01

Please sign in to comment.