PowerShell / Microsoft.PowerShell.Archive

Archive PowerShell module contains cmdlets for working with ZIP archives
https://technet.microsoft.com/en-us/library/dn818910.aspx
MIT License
94 stars 37 forks source link

Expand-Archive does not honor -Confirm:$false #105

Closed ChrisLynchHPE closed 3 years ago

ChrisLynchHPE commented 4 years ago

Steps to reproduce

Using the following command will prompt you to confirm the creation of sub-directories if they exist within the ZIP (like a Hyper-V VM template in ZPI form)

$Path = "C:\Mydirectory\archive.zip"
Expand-Archive -Path $Path -DestinationPath $env:TEMP\MyTempDirectory -Confirm:$false                                                                                                                      

Expected behavior

When using Expand-Archive, the Cmdlet should honor the use of -Confirm:$false, especially when creating directories that do not exist.

Actual behavior

When passing the -Confirm:$False parameter, the user is prompted for confirmation to create the destination directory, or any embedded child directory within the ZIP archive.

$Path = "C:\Mydirectory\archive.zip"
Expand-Archive -Path $Path -DestinationPath $env:TEMP\MyTempDirectory -Confirm:$false 
Unzipping C:\Mydirectory\archive.zip                                    
Confirm
Are you sure you want to perform this action?
Performing the operation "Create Directory" on target "Destination: 
C:\Users\username\AppData\Local\Temp\MyTempDirectory ". 
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):  Y

Are you sure you want to perform this action?
Performing the operation "Create Directory" on target "Destination:
C:\Users\username\AppData\Local\Temp\MyTempDirectory\EmbeddedDir1 ". 
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): 

Environment data

Windows 10, 1909

[PS] C:\Windows\System32> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
iSazonov commented 4 years ago

Docs says that -Force suppresses confirmation.

vexx32 commented 4 years ago

Yep, another command that chose to use -Force instead of a common parameter for prompts. Makes you wonder why they even bothered to implement ShouldProcessing. 😔

ChrisLynchHPE commented 4 years ago

Except -Force doesn't work either. I tried that. Same result.

vexx32 commented 4 years ago

@ChrisLynchHPE not to be bunting you all over the place, but as far as I recall the *-Archive cmdlets aren't managed in this repo; I think they live in the Microsoft.PowerShell.Archive repo; you'd need to file the issue there.

With any luck, @romero126 might be able to sneak that fix in before / after he gets his major work sorted out there, assuming there's still interest in developing that module further...

romero126 commented 4 years ago

I believe that whole Function is planned to get an overhaul soon.

Which would be better use of cycles? Fix a bug or release a future facing feature?

Im actually curious.

Also This bug should be in Microsoft.Powershell.Archive repository.

iSazonov commented 4 years ago

I ask MSFT team without answer https://github.com/PowerShell/Microsoft.PowerShell.Archive/issues/19#issuecomment-610500841

ghost commented 4 years ago

This issue has been marked as answered and has not had any activity for 1 day. It has been closed for housekeeping purposes.

ChrisLynchHPE commented 4 years ago

@romero126 Sorry for the late reply here. If working on a new feature to this Cmdlet fixes the issue, to me it doesn't matter. As long as it is fixed.