Expand-7zip Powershell

0 views
Skip to first unread message

Boyan Atanaschev

unread,
Aug 4, 2024, 2:21:55 PM8/4/24
to bemorringlo
Ive also started using 7-Zip as my program of choice for all kinds of backups, so I need to run it from batch files and Powershell scripts. Fortunately, there's a command line version of 7-Zip that doesn't need to be installed: 7za.exe (the a stands for stand-Alone). You can copy it onto any Windows PC and it'll just work. It's not too hard to use, but I like having Powershell's argument checking and help system, so I can type:

My personal favorite is New-7zSfx. This cmdlet creates a self-extracting archive, i.e. an executable file that will extract its contents to some temporary directory, run a command of your choosing (like "setup") and clean up after itself. Great for distributing MSI installation packages, or single-use tools that require no installation.


This operation is not as straightforward as the others. First, a 7-Zip archive is made (always of type 7z, not zip) that contains the necessary files. Then, a configuration file is created that contains the parameters for the extraction and the command to execute after that. This configuration files is then combined with 7zsd.sfx (a special file that contains the extraction logic), and the newly created archive itself to form the actual executable.


Make sure you download 7-Zip from 7-Zip.org. Extract 7za.exe (from the main download) and 7zsd.sfx (from the Extras download) and place them in the same directory as the powershell module 7-Zip.psm1. The module won't work without them!


I believe the issue is when Zipping back up the directory using a compress archive function available in PS V5, we miss out on some settings or configuration in the YXZP file itself where alteryx asks to load the package after import. Has anyone encountered something similar, or know something involving ZIP/YXZP extensions that allow alteryx to load after import?


I got a crazy idea for you. How about not converting to zip from YXZP at the beginning? I don't. I always can unzip straight from a yxzp. Not sure how powershell handles it but are you stuck with powershell only? I just know that if I am manually right click on something like 7zip it will extract it straight from yxzp. makes sense?


@CamodCPA There is a "comment" field that has to be set to the workflow name. I can check the comment field using 7-zip. See this post here. Assuming you're not changing any file names, could you skip your delete step (4) and use an -Update flag in your step 5? That way you can use the comment from the original yxzp. I don't know powershell so I'm just guessing. -us/powershell/module/microsoft.powershell.archive/compress-archive?vie...


I have a large 7z file(greater than 1TB) on a blob storage in Azure and would like to expand and store it in another blob storage. I tried creating a pipeline in ADF to utilise an automation account that runs a runbooks for 7zip4powershell module and a powershell script. The pipeline works by taking downloading a file from bolb, expanding and uploading it back, which works well for 7z files of less size( less than a 100mb), but fails for larger files and shows the error: "Get-AzureStorageBlobContent : There is not enough space on the disk."


In your case it seems you may be using custom activity. Kindly correct me if I am wrong. Check your Integration runtime where its running and try have enough space on that machine to complete this operation. Feel free to share your activity name which are using to run your runbooks.


I am trying to extract hundreds of zip files that are 10 GB large. I wrote a powershell script that is going through all the zip files and extracting them. I first used the extract-archive built in commandlet. It's been working for weeks running basically 24x7 extracting the files. But it started to fail today. I noticed the .zip files that are failing with powershell I can extract them using 7-zip using the GUI. I tried to add it to my script. Below is my code...


But, if I open the same .zip file in 7-Zip's GUI, I can extract it without issue. Any ideas what I'm doing wrong at the command line? Seeing it's in the program files folder and not the program files (x86), it appears the executable should be 64 bit and able to see large files...


also thinking the try catch isn't working because the extract-archive has the ErrorAction Stop argument on it which tells it to stop processing and jump to the catch.... but I'm not specifying that for the 7zip command... but 7zip isn't a powershell commandlet, so I can't.


Both of these work, indeed it would appear using a similar approach (powershell using .Copyhere). However both of them appear to require that the source zip file is located on a local drive. The reidmv/unzip README says this :-source

The fully-qualified path to the zip file to extract. This file must already exist on the system; that is, it cannot be a remote URL. You can use pget or another resourceThe zip file that I want to use is on a network share (actually while I'm testing its a sync folder in Vagrant, but will be on a network share when I move beyond this stage). When I use that location in the source, the module doesn't fail or error, it just doesn't unzip any of the files. If I move the file locally it works correctly. The same behaviours is true for the counsel/puppet-windows module.Is this a constraint of powershell or is there something else at play here ?Is there another way that I can unzip a file that is not located on the local machine (I would prefer not to have to install 7zip or similar if possible, but I will if that's the only way) ?Here is the command used in the reidmv/unzip module (it's wrapped into an Exec resource) :-exec "unzip $source to $dest":

command => "\$sh=New-Object -COM Shell.Application;\$sh.namespace((Convert-Path '$dest')).Copyhere(\$sh.namespace((Convert-Path '$source')).items(), 16",

creates => $creates,

provider => powershell


Having a hell of a time figuring out which installer to use for a 64 bit adobe reader deployment via intune win32 app. I located a good process at =TVAADl2J65Y for the 32 bit version, but I cant find an offline 64 bit installer that will let me extract the MSI from it.


To install Adobe Reader using MSI files, you need to download offline installer for Adobe reader from here Adobe Reader Enterprise. After Downloading, unzip de exe file with 7zip or WinRAR. Inside of folder, you will also find the msi file. You need to use the entire folder for installation, not only MSI installer.


I think i figured it out. The English US language selection does not give you a 64 bit DL. Unfortunately, I had to use the all languages MUI installer which is twice the size of the 32 bit version i first attempted. It works, but 1GB for an intune app... welcome to adobe enterprise standards i guess.


Hello,

After downloading the offline installer of Adobe Reader DC x64 (exe file) and extract its contents with 7zip, you get several files, including a msi and msp. But that standalone msi file is not the latest version of Reader DC, hence the msp file which probably contains the updates. However, I can only load a msi file in Intune, so how do I get a single msi files that corresponds to the latest version of Adobe Reader DC ?


Step 4

Use the files to create a package. I'm installing the up-to-date .msp with the msi (see here). Note that the msi is called acropro.msi but contains the reader. The msi can be executed like this:


Hi, I'm not sure about autopilot. But I usually deploy MSI packages in Intune using a win32 application though I wrap the application/installer in a powershell app deployment package. (example: -app-packaging-a-beginners-guide-part-1-win32/).

But you can also use a simple powershell script to start the installation -to-deploy-an-msi-using-powershell-script-and-intune/

Either way you add all the files to a directory (including the powershell script/batch script/PADT script), create the .intunewin file using IntuneWinAppUtil (you can download that from Microsoft), add a win32application to intune which executes the script you wrote and use the msi guid as dectection rule.


it can be challenging due to limited availability and distribution methods. Adobe may be prioritizes their streamlined web installers, which complicates deploying via tools like Intune. One solution is to use the enterprise distribution page or Adobe Customization Wizard to create a deployable package.!


The espionage group Earth Kapre (aka RedCurl and Red Wolf) has been actively conducting phishing campaigns targeting organisations in Russia, Germany, Ukraine, the United Kingdom, Slovenia, Canada, Australia, and the US. It uses phishing emails that contain malicious attachments (.iso and.img), which lead to successful infections upon opening. This triggers the creation of a scheduled task for persistence, alongside the unauthorised collection and transmission of sensitive data to command-and-control (C&C) servers.


The Trend Micro Managed Extended Detection and Response (MDR) and Incident Response (IR) team conducted an investigation of an incident where numerous machines were infected by the Earth Kapre downloader. This piece of malware was observed establishing connections with its C&C servers, suggesting a potential data theft scenario. Interestingly, in this instance, Earth Kapre has returned to using a previously known technique that is distinct from its more recent campaigns: It used legitimate tools Powershell.exe and curl.exe to procure the subsequent stage downloader. In an attempt to blend into the network and evade detection, Earth Kapre was found to have used the Programme Compatibility Assistant (pcalua.exe) to execute malicious command lines.

3a8082e126
Reply all
Reply to author
Forward
0 new messages