Problem using Write-Zip

This topic contains 5 replies, has 3 voices, and was last updated by  Brecht Gijbels 3 years, 10 months ago.

  • Author
  • #11631

    Steve Froggatt

    OK guys, I have just come across powershell about a week ago, and have been busy playing with it, however I have an issue trying to run write-zip

    using the following script,

    $src = "z:\orders"
    $target = "c:\temp\"
    Get-ChildItem $src -recurse | Write-zip -outputpath $target

    i am getting the following error
    Write-Zip : Skipping IAN RUFUS. It is not under the entry path root C:\Users\steve.
    At line:3 char:40
    + Get-ChildItem $src -recurse | Write-zip <<<< -outputpath $target + CategoryInfo : NotSpecified: (Z:\orders\Outstanding\IAN RUFUS:String) [W rite-Zip], ArgumentException + FullyQualifiedErrorId : FileError,Pscx.Commands.IO.Compression.WriteZipCommand I have extracted Pscx2.1.1 to my documents folder as suggested in the release notes and run import-module pscx. Any ideas, thanks

  • #11632

    Dave Wyatt

    I haven't found the part of the source code that actually produces that error, but there is a parameter named EntryPathRoot that seems like it should solve that problem:

    Get-ChildItem $src -recurse | Write-zip -outputpath $target -EntryPathRoot $src
  • #11634

    Steve Froggatt

    Thanks Dave
    that worked, strange thing is i did the same on my works computer and everthing worked ok.

  • #18255

    Brecht Gijbels

    I'm having the same error message on a fresh installation (Win Srv 2008, PS 4.0, Pscx 3.1):

    Get-ChildItem -Recurse 'S:\Test\SourceDir' | Write-Zip -OutputPath 'S:\Test\\' -IncludeEmptyDirectories
    Write-Zip : Skipping TestFile. It is not under the entry path root C:\

    The proposed work around doesn't work either:

    $Test = Get-ChildItem -Recurse 'S:\Test\SourceDir'
    $Test | Write-Zip -OutputPath 'S:\Test\' -IncludeEmptyDirectories -EntryPathRoot $Test
    Write-Zip : Cannot convert 'Pscx.IO.PscxPathInfo[]' to the type 'Pscx.IO.PscxPathInfo' required by parameter 'EntryPathRoot'. Specified method is not supported.
    At line:2 char:99
    + ... -EntryPathRoot $Test
  • #18259

    Dave Wyatt

    That's not quite the proposed workaround. You're passing the results of Get-ChildItem to the EntryPathRoot parameter, but what you should be passing is the same directory name that you passed to Get-ChildItem (in this case, 'S:\Test\SourceDir' ). Try this:

    Get-ChildItem -Recurse 'S:\Test\SourceDir' |
    Write-Zip -OutputPath 'S:\Test\' -IncludeEmptyDirectories -EntryPathRoot 'S:\Test\SourceDir'
  • #18260

    Brecht Gijbels

    Thank you Dave, you're right. I've tried it and it works flawlessly now. Very strange that I have to use this piece:

    -EntryPathRoot 'S:\Test\SourceDir'


    But I'm glad it works now, thanks again 🙂

You must be logged in to reply to this topic.