Microsoft.PowerShell.Archive
Microsoft.PowerShell.Archive copied to clipboard
Compress-Archive should have a -SkipBaseDirectory switch
When I run
Compress-Archive $pwd -Destination ..\Compressed.zip
I always get a (redundant) single top-level folder in the zip
We need an option to not create that top level folder.
Note that this does not work:
Get-ChildItem $pwd | Compress-Archive -Destination ..\Compressed.zip
Because the resulting zip will be missing any empty subfolders of $pwd
My current workaround is to use:
[System.Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem")
[System.IO.Compression.ZipFile]::CreateFromDirectory('c:\tmp\somedir', 'c:\tmp\foo.zip', 'Optimal', $false)
Duplicating the root folder is problematic with the .Nupkg format.
I have tried the workaround of @sba923 but the compressed file cannot be expanded on some clients by chocolatey packages.
When I zip the same folder with Right-Click\Send To\Compressed (Zipped) folder it works fine, but I cannot automate this...