Closed GeneralBouLi closed 2 years ago
Related PowerShell/PowerShell#12168 ##6232
In .Net wildcards, [] are used to specify a selection, (similar to regular expressions) so
dir "*.[pqr]s1"
in Powershell will return .ps1, .qs1 and .rs1 files.
and dir *ps[0-9]
will return .ps0, ps1 ... ps9
MANY things will treat [] as invalid, even though the file system allows them. So you get this sort of thing
dir > 'test[1]'
Out-File: Cannot perform operation because the wildcard path test[1] did not resolve to a file.
dir > 'test`[1`]'
works and if use double quotes you need to double up the backquote.
Your code will work if you use
-DestinationPath ([WildcardPattern]::Escape( "C:$UNZIP_DIRECTORY[TEST]"))
Expand-Archive
may need to have path parameters like LiteralPath
to support what's asked in the issue.
@SteveL-MSFT can you please move the issue to the Archive repo?
@SteveL-MSFT looks like this issue can be moved to the Archive repo
Prerequisites
Steps to reproduce
Execute : Expand-Archive -Path "$ZIP_DIRECTORY\$ZIP_NAME" -DestinationPath "C:\$UNZIP_DIRECTORY[TEST]"
No problem with : Expand-Archive -Path "$ZIP_DIRECTORY\$ZIP_NAME" -DestinationPath "C:\$UNZIP_DIRECTORY\TEST"
Expected behavior
Actual behavior
Error details
Environment data
Visuals
No response