I need to pack a folder using Compress-Archive
in PShell
My folder structure is as following:
|- C:\MyFolder
|--- Files
|------ Start.ps1
|------ Stop.ps1
|--- Manifests
|------ Start.xml
|------ Stop.xml
When I issue this command Compress-Archive -Path "C:\MyFolder" -DestinationPath "C:\MyFolder.zip"
The result is a .zip which has a root folder called "MyFolder" while what I need is a .zip which replicate the tree of MyFolder without having MyFolder as the root one. Is that possible?
The
Path
parameter accepts specific file names and file names with wildcards. So instead ofC:\MyFolder
asPath
parameter you could do pass"C:\MyFolder\*
"(all its files and subdirectories hence skipping the root directory)This is also documented here,