Last active
October 27, 2020 12:57
-
-
Save eddiezato/86117e1783a4d0ef0692a2f17bf2c0d0 to your computer and use it in GitHub Desktop.
Sample pwsh script for extract with sevenzipsharp
This file contains 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
Add-Type -Path "$PSScriptRoot\SevenZipSharp.dll" | |
[SevenZip.SevenZipBase]::SetLibraryPath("$Env:UserProfile\Portable\Console\7z.dll") | |
$zipfile = New-Object SevenZip.SevenZipExtractor("$PSScriptRoot\armando_huerta.zip") | |
$temp = ($zipfile.ArchiveFileNames | Where-Object { -not $_.Contains("\") }) | |
$null = Register-ObjectEvent -InputObject $zipfile -EventName "Extracting" -SourceIdentifier "Extracting" -Action { | |
Write-Progress -Activity "armando_huerta.zip" -Status "Extracting" -PercentComplete $EventArgs.PercentDone | |
} | |
$null = Register-ObjectEvent -InputObject $zipfile -EventName "ExtractionFinished" -SourceIdentifier "ExtractionFinished" -Action { | |
Stop-Job -Name "Extracting" | |
Remove-Job -Name "Extracting" | |
Write-Progress -Activity "armando_huerta.zip" -Status "Extracting" -Completed | |
$null = New-Event -SourceIdentifier "AllDone" | |
} | |
$zipfile.BeginExtractArchive($PSScriptRoot) | |
$null = Wait-Event -SourceIdentifier "AllDone" | |
Remove-Event -SourceIdentifier "AllDone" | |
Stop-Job -Name "ExtractionFinished" | |
Remove-Job -Name "ExtractionFinished" | |
$zipfile.Dispose() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment