PowerShell-Profile/functions/Get-FileSize.ps1
2024-05-01 14:12:54 +02:00

24 lines
504 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 [PSCustomObject]@{
"Bytes" = $fileSizeBytes
"KB" = $fileSizeKB
"MB" = $fileSizeMB
"GB" = $fileSizeGB
}
}