Get exclusions from file PowerShell

Welcome Forums General PowerShell Q&A Get exclusions from file PowerShell

Viewing 5 reply threads
  • Author
    Posts
    • #250955
      Participant
      Topics: 2
      Replies: 4
      Points: 18
      Rank: Member

      Hello there,
      I just want to set extension exclusion from file (7zip utilization). If I write this command, it’s work perfectly :
      7zip a -t7z -m0=lzma2 -mx=9 -mmt=on -mhe=on -p"$Password" $Target $itemsToSave '-xr!*.lck' '-xr!*.log'
      But, if I want to take exclusions from file in PowerShell, It doesn’t work :

      Here the result of file (exactly the same output with write-host $exclusion) :
      '-xr!*.lck' '-xr!*.log'
      Someone can help me ?

      Thanks,
      Clement.

    • #251117
      Participant
      Topics: 0
      Replies: 81
      Points: 362
      Helping Hand
      Rank: Contributor

      Do the exclusion.txt file items contain the surrounding quotes? If so, they probably don’t need to be there.

    • #251132
      Participant
      Topics: 2
      Replies: 4
      Points: 18
      Rank: Member

      Hello,

      I tried with one, double quotes and without, but doesn’t work :/

    • #251768
      Participant
      Topics: 8
      Replies: 568
      Points: 2,170
      Helping Hand
      Rank: Community Hero

      We are left to assume what you have in $target and $itemstosave – the question I am stuck at is why are you including items in $itemstosave that you want to exclude. Just exclude them when making your list. If this isn’t the case, please provide details about what you’re actually running. If I run your test with a path as the $itemstosave, the exclusions were ignored in the format specified.

    • #252578
      Participant
      Topics: 2
      Replies: 4
      Points: 18
      Rank: Member

      Hello,

      because in $itemtosave, i just set 4-5 generals folders. One folder can have 1000 or more files…

      In $exclusion, I just want to exclude 2-3 extensions like *.lck, *.log or others…

      “If I run your test with a path as the $itemstosave, the exclusions were ignored in the format specified”

      –> Really ? 😮 I am running 7Zip 19.00, PWSH 5.1 (and 7.0.3).

       

       

    • #255371
      Participant
      Topics: 2
      Replies: 4
      Points: 18
      Rank: Member

      Here a solution for someone who’s want do the same :
      7zip a -t7z -m0=lzma2 -mx=9 -mmt=on -mhe=on -p”$resultPasswordArchive” $Target $itemsToSave1 [email protected]”exclusion.txt”
      In fileexclusion.txt, insert exclusions you want like :

      *.log
      *.lck

      Problem solved.
      Clement.

Viewing 5 reply threads
  • You must be logged in to reply to this topic.