Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- param (
- [string]$zipPath
- )
- # Used in dayz-bak.ps1 after zip generation but could be used other places as well.
- # call like .\AnalyzeZip.ps1 $destZip to execute remotely
- Add-Type -Assembly System.IO.Compression.FileSystem
- # testing $zipPath="e:\dayz_backups\2501240336-dayz-server-bak.zip"
- $zip = [IO.Compression.ZipFile]::OpenRead($zipPath)
- $fileCount = $zip.Entries.Count
- $totalSize = 0
- foreach ($entry in $zip.Entries) {
- $totalSize += $entry.Length
- }
- $zip.Dispose()
- # Convert size to a human-readable format
- function Get-HumanReadableSize {
- param ([long]$bytes)
- $suffix = @("B", "KB", "MB", "GB", "TB")
- $i = 0
- while ($bytes -ge 1kb -and $i -lt $suffix.Length - 1) {
- $bytes = $bytes / 1kb
- $i++
- }
- return "{0:N2} {1}" -f $bytes, $suffix[$i]
- }
- "Number of files: $fileCount"
- "Total size: $(Get-HumanReadableSize -bytes $totalSize)"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement