Optionally, you can use the -CompressionLevel parameter with one of three values: Optimal, NoCompression or Fastest. The command below adds all the files in the Invoices folder to my existing Invoices.zip archive: Compress-Archive -Path C:Invoices* -Update -DestinationPath C:ArchivesInvoices To add files to an archive, use the -Update parameter. Without the -Force parameter, you cannot overwrite existing archives and PowerShell will prompt you to add files to the archive instead. Note that I added the -Force parameter to overwrite the archive that I created using the first command. This command creates an archive with just the two files explicitly listed in the – LiteralPath parameter: Compress-Archive -LiteralPath C: InvoicesFile1.txt, C:InvoicesFile2.txt -DestinationPath C:ArchivesInvoices -Force The command below will zip the Invoices folder in the root C directory and create an archive called Invoices.zip in the Archives folder: Compress-Archive -Path C:Invoices -DestinationPath C:ArchivesInvoicesĪlternatively, we could zip the files in the Invoices folder individually using -LiteralPath instead of – Path. All you need to do is use the -Path parameter to specify the folder you want to compress and the – DestinationPath parameter to specify the name of the archive you want to create. Let’s start by using PowerShell to compress files in a new zip archive. If you don’t already have PowerShell 5.0 or later installed on your systems, you can download the latest version of the Windows Management Framework from Microsoft’s website.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |