Get all the files you want to compress, except for the files and folders that you don't want to compress, and then pass them to the cmdlet
# target path $path = "C:\temp" # construct archive path $DateTime = (Get-Date -Format "yyyyMMddHHmmss") $destination = Join-Path $path "ARCHIVE\archive-$DateTime.zip" # exclusion rules. Can use wild cards (*) $exclude = @("_*.config","ARCHIVE","*.zip") # get files to compress using exclusion filer $files = Get-ChildItem -Path $path -Exclude $exclude # compress Compress-Archive -Path $files -DestinationPath $destination -CompressionLevel Fastest
Nkosi source share