Search code examples
powershellcmd

Create zip file by cmd exclude 1 file. Compress-Archive


I tried to zip files from a given folder excluding one folder doing it with one command.

It is based on How do I exclude a folder in compress-archive

I am trying

powershell Compress-Archive -Path "Get-ChildItem * -Exclude Sql -Name" -DestinationPath ..\..\Products\File4.zip

It throws

Compress-Archive : A positional parameter cannot be found that accepts argument '*'.

When I use command powershell Get-ChildItem * -Exclude Sql -Name it work.

It is possible to this it in this way?


Solution

  • use this syntax:

    Compress-Archive -Path (Get-ChildItem * -Exclude Sql -Name) -DestinationPath .....