PowerTip: Use PowerShell 5 to Compress Files

Doctor Scripto

Summary: Learn how to use the new Compress-Archive cmdlet to compress selected files in Windows PowerShell 5.0.

Hey, Scripting Guy! Question How can I compress a bunch of files on my computer that match a pattern I supply to Get-ChildItem?

Hey, Scripting Guy! Answer Use Get-ChildItem to find the files you want to compress, and pipe the results to the Compress-Archive cmdlet,
           for example (gci is an alias for Get-ChildItem):

gci c:\fso\*.txt | Compress-Archive -DestinationPath c:\fso\myarchive.zip

0 comments

Discussion is closed.

Feedback usabilla icon