Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

Expand-Archive doesn't work with UNC paths expressed with forward slashes #95

Open
sba923 opened this issue May 22, 2020 · 1 comment
Open

Comments

@sba923
Copy link

sba923 commented May 22, 2020

This works fine (specifying the destination path using forward slashes):

Expand-Archive -LiteralPath C:\tmp\foo.zip -Force -DestinationPath c:/tmp

but this doesn't:

Expand-Archive -LiteralPath C:\tmp\foo.zip -Force -DestinationPath //pnjnas/public                                    Write-Error: C:\program files\powershell\7\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1:404   Line |                                                                                                                   404 |  …             ExpandArchiveHelper $resolvedSourcePaths $resolvedDestina …                                            |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Can not process invalid archive entry 'foo.txt'.


> get-error

Exception             :
    Type    : Microsoft.PowerShell.Commands.WriteErrorException
    Message : Can not process invalid archive entry 'foo.txt'.
    HResult : -2146233087
CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,ExpandArchiveHelper
InvocationInfo        :
    MyCommand        : ExpandArchiveHelper
    ScriptLineNumber : 404
    OffsetInLine     : 17
    HistoryId        : 87
    ScriptName       : C:\program
files\powershell\7\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1
    Line             : ExpandArchiveHelper $resolvedSourcePaths $resolvedDestinationPath ([ref]$expandedItems) $Force
$isVerbose $isConfirm

    PositionMessage  : At C:\program
files\powershell\7\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1:404 char:17
                       + …             ExpandArchiveHelper $resolvedSourcePaths $resolvedDestina …
                       +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    PSScriptRoot     : C:\program files\powershell\7\Modules\Microsoft.PowerShell.Archive
    PSCommandPath    : C:\program
files\powershell\7\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1
    InvocationName   : ExpandArchiveHelper
    CommandOrigin    : Internal
ScriptStackTrace      : at ExpandArchiveHelper, C:\program
files\powershell\7\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1: line 1006
                        at Expand-Archive<Process>, C:\program
files\powershell\7\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1: line 404
                        at <ScriptBlock>, <No file>: line 1

The workaround is to use backslashes in the UNC path:

Expand-Archive -LiteralPath C:\tmp\foo.zip -Force -DestinationPath \\pnjnas\public                                    

Environment details:

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.0.1
PSEdition                      Core
GitCommitId                    7.0.1
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


> Get-Module Microsoft.PowerShell.Archive | Select *

LogPipelineExecutionDetails : False
Name                        : Microsoft.PowerShell.Archive
Path                        : C:\program
                              files\powershell\7\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psd1
ImplementingAssembly        :
Definition                  :
Description                 : PowerShell module for working with ZIP archives.
Guid                        : eb74e8da-9ae2-482a-a648-e96550fb8733
HelpInfoUri                 : https://go.microsoft.com/fwlink/?LinkId=2113631
ModuleBase                  : C:\program files\powershell\7\Modules\Microsoft.PowerShell.Archive
PrivateData                 :
ExperimentalFeatures        : {}
Tags                        : {}
ProjectUri                  :
IconUri                     :
LicenseUri                  :
ReleaseNotes                :
RepositorySourceLocation    :
Version                     : 1.2.5
ModuleType                  : Manifest
Author                      : Microsoft Corporation
AccessMode                  : ReadWrite
ClrVersion                  :
CompanyName                 : Microsoft Corporation
Copyright                   : © Microsoft Corporation. All rights reserved.
DotNetFrameworkVersion      : 4.5
ExportedFunctions           : {[Compress-Archive, Compress-Archive], [Expand-Archive, Expand-Archive]}
Prefix                      :
ExportedCmdlets             : {}
ExportedCommands            : {[Compress-Archive, Compress-Archive], [Expand-Archive, Expand-Archive]}
FileList                    : {}
CompatiblePSEditions        : {}
ModuleList                  : {}
NestedModules               : {Microsoft.PowerShell.Archive}
PowerShellHostName          :
PowerShellHostVersion       :
PowerShellVersion           : 3.0
ProcessorArchitecture       : None
Scripts                     : {}
RequiredAssemblies          : {}
RequiredModules             : {}
RootModule                  :
ExportedVariables           : {}
ExportedAliases             : {}
ExportedDscResources        : {}
SessionState                : System.Management.Automation.SessionState
OnRemove                    :
ExportedFormatFiles         : {}
ExportedTypeFiles           : {}
@ayousuf23
Copy link
Contributor

ayousuf23 commented Aug 18, 2022

I believe this is fixed, but I haven't tested it in Expand-Archive.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants