Powershell password protected file Hi, I'm new to powershell and try to learn some trick with it. I created a simple code that's supposed to unzip a file using 7zip and a known password.
Here's the code:
$7ZipPath = '"C:\Program Files\7-Zip\7z.exe"'
$zipFile = '"C:\Users\touff\OneDrive\Bureau\0\Encrypted Zip\test.zip"'
$path = 'C:\Users\touff\OneDrive\Bureau\0\Encrypted Zip\foldertest'
New-Item -ItemType directory -Path $path
Read-Host -Prompt 'step1'
$password = Read-Host -Prompt 'Input the password'
Write-Host $password
$command = "& $7ZipPath e -oC:\ -y -tzip -p$password $zipFile"
Invoke-Expression $command
I keep getting these errors :
7-Zip [64] 16.04 : Copyright (c) 1999-2016 Igor Pavlov : 2016-10-04
Scanning the drive for archives:
1 file, 310 bytes (1 KiB)
Extracting archive: C:\Users\touff\OneDrive\Bureau\0\Encrypted Zip\test.zip
Path = C:\Users\touff\OneDrive\Bureau\0\Encrypted Zip\test.zip
Type = zip
Physical Size = 310
ERROR: Can not open output file : Accès refusé. : C:\ok.txt
Sub items Errors: 1
Archives with Errors: 1
Sub items Errors: 1