0

I want to achrive content of shared folder, but it's not working with this command: Copy-Item -Path $source -Force -PassThru | Get-ChildItem | Compress-Archive -DestinationPath $destination

If $source = C:\MyNormalFolder than it's working, but if I use
C:\MySharedFolder or \\MyPC\MySharedFolder, it doesn't work. I get no error, just see empty destination folder.

In that folder are files used by other processes, that's why I can't use just Compress-Archive. Do you have any idea how to solve it?

Theo
  • 57,719
  • 8
  • 24
  • 41
  • What is in `$destination` ? _The DestinationPath should include the name of the zipped file, and either the absolute or relative path to the zipped file._ – Theo Nov 25 '20 at 14:28
  • Destination is some folder + datetime + .zip. Problem is in source folder. If I use non-shared folder, it creates zip files as I wish, but if use shared folder in source, it create no file. – Pavel Mazalek Nov 26 '20 at 13:46
  • The [Compress-Archive](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.archive/compress-archive) cmdlet has a limit. The maximum file size is 2 GB because there's a limitation of the underlying API. Perhaps the files and folders you try to add to the zip exceed this limit? Try doing this with 7zip – Theo Nov 26 '20 at 13:53
  • That is good point. Thanks :-) – Pavel Mazalek Nov 27 '20 at 07:49

0 Answers0