Created
November 14, 2012 03:54
-
-
Save abombss/4070162 to your computer and use it in GitHub Desktop.
Powershell List Zip Archive File Contents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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