7Zip4Powershell icon indicating copy to clipboard operation
7Zip4Powershell copied to clipboard

Access to path is denied

Open nlvw opened this issue 8 years ago • 4 comments

I'm trying to compress multiple folders into separate zip files however I keep getting "Access to path is denied". if I run 7za.exe by itself it can zip the folders just fine.

My Script:

$folders = Get-ChildItem -Exclude ".mig",".zip","_Easy File Transfer (migwiz)" $env:Path = $env:Path + ";K:\TechStuff\Tech_Software\7za"

foreach($folder in $folders) {

Compress-7Zip -Path $folder.Name -Format Zip -CompressionLevel None -ArchiveFileName ($folder.Name + ".zip")

}

Error:

Compress-7Zip : Access to the path 'K:\Profile Backups\spatrico' is denied. At line:6 char:5

  • Compress-7Zip -Path $folder.Name -Format Zip -CompressionLevel No ...
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (SevenZip4PowerS...+CompressWorker:CompressWorker) [Compress-7Zip], UnauthorizedAccessException
    • FullyQualifiedErrorId : err01,SevenZip4PowerShell.Compress7Zip

nlvw avatar Feb 29 '16 19:02 nlvw

So I dug into this a little more and found that for whatever reason (I have no idea why) Compress-7Zip will not working over Powershell Remoting. Using the same credentials the script will fail if run remotely and work if run from remote desktop.

nlvw avatar Feb 29 '16 19:02 nlvw

I've never used PowerShell Remoting before. However, as far as I understand it, the module is copied to the remote machine automatically. I guess that the remoting mechanism doesn't copy the required native DLLs 7z.dll and 7z64.dll, and the 7Zip4PowerShell can't find them on the remote machine. Can you verify that?

thoemmi avatar Feb 29 '16 21:02 thoemmi

While in the remote session I did a "install-module" and pulled the module down to the remote machine from the powershell gallery. Also for reference i've always had to install-modules manually on the remote machine before they are usable for remoting.

nlvw avatar Feb 29 '16 23:02 nlvw

I just installed the 1.13 module today, locally in Powershell 5.1 on Windows 10. I tried to 7zip files in a directory I created and had a few pdf files in. I was running Powershell as Administrator. Whenever I try to compress anything, I get this message:

Compress-7Zip : Access to the path 'C:\WINDOWS\system32\config\systemprofile\AppData\Local\Microsoft\Windows\INetCache\Content.IE5' is denied.

Why this directory is being used instead of %TEMP%, I'm not certain. This directory doesn't even exist.

My command line was this:

Compress-7Zip -Path . -Filter *.pdf -ArchiveFileName .\stuff.7z

wehnertb avatar Sep 07 '20 18:09 wehnertb