Search code examples
powershellpscx

How can I exclude certain file types when using Powershell and the PSCX Write-Zip cmdlet?


How can I exclude certain file types when using Powershell and the PSCX Write-Zip cmdlet?

Right now I'm using this:

Write-Zip -Path "C:\Program Files (x86)\Folder" -OutputPath
"C:\newDeploy\backup\Folder.zip" -IncludeEmptyDirectories -NoClobber -Level 1

I need it to include the directory structure in the ZIP and I also need to exclude certain file types (eg: .txt).

Thank you for your help :)

-Jim


Solution

  • The closest I can come in this:

    cd "C:\Program Files (x86)\Folder"
    Get-ChildItem . -r -Exclude *.txt | Write-Zip -OutputPath c:\temp\folder.zip -IncludeEmptyDirectories -NoClobber -Level 1
    

    but this doesn't seem to be honoring the request to include empty dirs.