PowerShell-Profile/functions/Get-FileSize.ps1
Tomasz Kostrzewa 566c2a3e97 renamed: functions/Get-FileSize -> functions/Get-FileSize.ps1
renamed:    functions/Get-FileSize copy -> functions/Get-ObjectCount.ps1
2024-03-05 23:07:11 +01:00

24 lines
488 B
PowerShell

# gitea.RdzeN.net
#
# Get filesize.
function Get-FileSize {
param (
[string]$FilePath
)
$fileInfo = Get-Item $FilePath
$fileSizeBytes = $fileInfo.Length
$fileSizeKB = [math]::Round($fileSizeBytes / 1KB, 2)
$fileSizeMB = [math]::Round($fileSizeBytes / 1MB, 2)
$fileSizeGB = [math]::Round($fileSizeBytes / 1GB, 2)
return @{
"Bytes" = $fileSizeBytes
"KB" = $fileSizeKB
"MB" = $fileSizeMB
"GB" = $fileSizeGB
}
}