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
When using Expand-Archive, the Cmdlet should honor the use of -Confirm:$false, especially when creating directories that do not exist.
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"):
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
Docs says that -Force suppresses confirmation.
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. 馃様
Except -Force doesn't work either. I tried that. Same result.
@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...
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.
I ask MSFT team without answer https://github.com/PowerShell/Microsoft.PowerShell.Archive/issues/19#issuecomment-610500841
This issue has been marked as answered and has not had any activity for 1 day. It has been closed for housekeeping purposes.
@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.
Most helpful comment
Yep, another command that chose to use
-Forceinstead of a common parameter for prompts. Makes you wonder why they even bothered to implementShouldProcessing. 馃様