Skip to content

Instantly share code, notes, and snippets.

@abombss
Created November 14, 2012 03:54
Show Gist options
  • Select an option

  • Save abombss/4070162 to your computer and use it in GitHub Desktop.

Select an option

Save abombss/4070162 to your computer and use it in GitHub Desktop.
Powershell List Zip Archive File Contents
function Get-ArchiveItems {
param([Parameter(Mandatory)][string]$Archive)
function recurse-items {
param([object]$items)
foreach($item in $items) {
$item
$folder = $item.GetFolder
if ($folder) {
recurse-items $folder.Items()
}
}
}
$Archive = Resolve-Path $Archive
$shellApp= New-Object -com shell.application
$zipArchive = $shellApp.NameSpace($zipArchive)
recurse-items $zipFile.Items() |% {
$zipPath = $_.Path.Replace($Archive + [System.IO.Path]::DirectorySeparatorChar,'')
$level = (Split-String -Input $zipPath -Separator ([string] [System.IO.Path]::DirectorySeparatorChar)).Count
$_ | Add-Member @{Archive=$Archive;Level=$level;Path=$zipPath} -PassThru -Force
} | Sort-Object Level, Name | Select * -ExcludeProperty Application,Parent,GetLink,GetFolder,Level
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment