- This topic has 5 replies, 3 voices, and was last updated 4 months, 1 week ago by
August 19, 2020 at 3:06 pm #250955
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 :PowerShell12$exclusion = get-content -Path "conf\exclusion.txt"7zip a -t7z -m0=lzma2 -mx=9 -mmt=on -mhe=on -p"$Password" $Target $itemsToSave $exclusion
Here the result of file (exactly the same output with write-host $exclusion) :
Someone can help me ?
August 20, 2020 at 2:01 am #251117ParticipantTopics: 1Replies: 95Points: 435Rank: Contributor
Do the exclusion.txt file items contain the surrounding quotes? If so, they probably don’t need to be there.
August 20, 2020 at 2:41 am #251132
I tried with one, double quotes and without, but doesn’t work :/
August 21, 2020 at 5:07 pm #251768ParticipantTopics: 9Replies: 702Points: 2,819Rank: 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.
August 26, 2020 at 9:48 am #252578
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).
September 8, 2020 at 3:45 pm #255371
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 :
- The topic ‘Get exclusions from file PowerShell’ is closed to new replies.