Attribute "A" missing in the zipped file through powershell "Compress-Archive" - powershell

Compressed a file through powershell Compress-Archive feature.
On opening the archive in the 7-zip there is no 'A' in the attribute column, i believe 'A' stands for archive.
When file compressed through windows feature (send to -> Compressed (zipped) folder) "A" attribute is present(When opened archive in 7-zip).
How can I get the 'A' attribute when zipped through Compress-Archive?
Real problem:
I am trying to unzip the file through puppet.
unzip working on files zipped through windows feature
unzip not working on Compress-Archive feature (only through puppet, normal unzip command is working)
On opening both the zipped files (through Compress-Archive, windows feature) in 7-zip archive I observed that attribute 'A' is missing in the zipped (Compress-Archive) file.
Please help.
Tagged puppet as well, could be a known scenario.

Related

[IO.Compression.ZipFile]::ExtractToDirectory() & Expand-Archive issues with Zip of a single file

I am implementing a tool to address software installs for Work from Home staff, and trying to download ZIP files containing either a folder that is an Autodesk "deployment" or a single EXE or MSI update file. The folder containing ZIP is unzipping fine with
[IO.Compression.ZipFile]::ExtractToDirectory($downloadFilePath, $deploymentPath)
However, the ZIP files that contain nothing but a single file are throwing
System.Management.Automation.MethodInvocationException
Exception calling "ExtractToDirectory" with "2" argument(s): "The archive entry was compressed using an unsupported compression method."
using
[IO.Compression.ZipFile]::ExtractToDirectory($downloadFilePath, $deploymentPath)
I also tried Expand-Archive -Path $downloadFilePath -DestinationPath $deploymentPath and there I get a similar error
System.Management.Automation.MethodInvocationException
Exception calling "ExtractToFile" with "3" argument(s): "The archive entry was compressed using an unsupported compression method."
But oddly, I am not using three arguments. Also note that both approaches work with the zip of a folder, while neither approach works with the zip of a file.
All ZIP files have been created with Right Click>Send to>Compressed (zipped) folder, highlighting either the deployment folder or the file to be zipped. And the problem ZIP file works fine to extract manually.
Any thoughts?

How to ZIP a whole folder( including Subfolders and files) using 7zip in PowerShell

I am trying to ZIP a whole folder( including Subfolders and files) using 7zip in PowerShell
Below is the code:-
& "$env:C:\Program Files\7-Zip\7zFM.exe" -mx=9 a "C:\Users\Rajat.Choudhary\Desktop\rajat\*" "C:\Users\Rajat.Choudhary\Desktop\backup.zip"
Every time the 7 Zip application opened when I executed this code in VS code editor.
Please suggest the solution for this.

Count files in a ZIP file over SFTP using PowerShell

I am connecting to SFTP via host, port, username and password using PowerShell. I want to count the number of files in a particular zip folder without having to download the zip folder on my local machine and count. Please share the piece of logic that would do this. I looked into this but it seems a bit tricky when it comes to do this in a zip folder.
That's not an easy task to do. There's no API in SFTP to do that completely remotely. There are basically two solutions:
Use SFTP to download only the ZIP central directory (basically the listing that is placed at the very end of the ZIP file). And decode the directory locally. For C#, this is covered in my answer to List files inside ZIP file located on SFTP server in C#. Though as mentioned there, there's a bug in SSH.NET that requires a workaround with implementing an interface. While that's probably doable in PowerShell too, I've never done that.
If you have an SSH shell access to the server, use remote zip command to list the contents of the file. Or build another API (like a web service).
Btw, note that there's nothing like ZIP "folder". ZIP is an archive file. It's only Windows that call ZIP files "folders".

How to move a file in to zip uncompressed, with zip cmd tool

I'm try to determine how to use the zip cmd line tool to move a file (uncompressed) in to a zip of compressed files (ie I want a zip in the end with all files but one compressed, b/c the one file is another compressed file).
Anyone know how to do this?
It looks like you could use -n option to just store the files with defined extensions together with -g option to append the file to archive.
I didn't test it, but something like this should do the trick:
zip -gn .foo archive.zip myAddedFile.foo
Although documentation states that, by default, zip does not compress files with extensions in the list .Z:.zip:.zoo:.arc:.lzh:.arj, so if you are adding a file with one of those extensions you should be fine.
Documentation to the command is here
-m is what I wanted, moves the file(s) into a zip.

Using wildcards for filenames in powershell

I am having a lot of issues trying to automate downloading from an ftp site. I know the folder the file will be in, and I know that it will be a .zip file. However I do not know what the files will be named.
So I have code that works if I know the file name...for example:
$sourceuri = "ftp://myFtpSite/test/myZipFile.zip"
I would like to be able to use wildcards in this string so it will recongize any zip file. So I could write something like
$sourceuri = "ftp://myFtpSite/test/_.zip"
and it would download any zip file in that folder.
I know this question is ancient, but have you considered just using the console app ftp.exe? You can build a text file with commands (such as "mget *.zip" to retrieve all .zip files) and automate the process.
ftp -s:filename