Skip to content

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

@ChrisLynchHPE

Description

@ChrisLynchHPE

Originally opened here https://github.com/PowerShell/PowerShell/issues/12590, but advised I open an issue on this repo instead.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions