diff --git a/Tools.ps1 b/Tools.ps1 index c3f7be0..7cbe4f8 100644 --- a/Tools.ps1 +++ b/Tools.ps1 @@ -187,6 +187,7 @@ Function Download-File { [Parameter(Mandatory=$false,ValueFromPipeline=$false)][string]$File ) If ( !($File) ) { $File = '{0}{1}' -f (Get-TempPath), (Split-Path $URL -Leaf) } + $URL = Get-AbsoluteURI -URL $URL If ( IsURLValid $URL ) { If ( Test-Path $File ) { Write-Output "Deleting existing file: ""${File}""" @@ -787,9 +788,9 @@ Function Test-RegistryProperty { } # Function to format a quantity of bytes into a denomination -Function Beautify-Bytes { +Function Format-ByteQuantity { param( - [int64]$Amount, + [int64]$TotalBytes, [int]$Precision=2, [string]$Units, [switch]$WithUnitLabel @@ -802,8 +803,8 @@ Function Beautify-Bytes { default { $UnitLabel = "bytes" ; $Divisor = 1 } } Switch ( $WithUnitLabel ) { - $true { Return (ZeroPad-Decimal -Amount $([Math]::Round($Amount / $Divisor,$Precision)) -NeededDecimalPlaces $Precision) + "${UnitLabel}" } - $false { Return (ZeroPad-Decimal -Amount $([Math]::Round($Amount / $Divisor,$Precision)) -NeededDecimalPlaces $Precision) } + $true { Return (ZeroPad-Decimal -Amount $([Math]::Round($TotalBytes / $Divisor,$Precision)) -NeededDecimalPlaces $Precision) + "${UnitLabel}" } + $false { Return (ZeroPad-Decimal -Amount $([Math]::Round($TotalBytes / $Divisor,$Precision)) -NeededDecimalPlaces $Precision) } } }