- 1 year ago
Windows 10 powershell ise compress-archive files at root .in .zip
To use PowerShell ISE to compress files at the root into a .zip archive, you can use the Compress-Archive
cmdlet. Here's how you can do it:
Open PowerShell ISE on your Windows 10 machine.
Load the files you want to compress into an array. For example, if you want to compress all .txt files at the root directory, you can use the following command to load them into an array:
powershell$filesToCompress = Get-ChildItem -Path C:\ -Filter *.txt
- Use the
Compress-Archive
cmdlet to compress the files into a .zip archive. Specify the output .zip file path and the files to compress using the array created in the previous step:
powershellCompress-Archive -Path $filesToCompress.FullName -DestinationPath C:\compressed_files.zip
Replace C:\
with the root directory where your files are located and adjust the filter (*.txt in this example) to match the files you want to compress.
The above command will create a new .zip file named compressed_files.zip
in the root directory containing all the .txt files found.
Note: The Compress-Archive
cmdlet is available in PowerShell 5.1 or later. If you are using an older version of PowerShell, you can install the PowerShell Community Extensions (PSCX) module or use other third-party compression tools like 7-Zip.