I want to use an array for the exclusion:
Remove-Item -Path "$InstallDir\Lang\*" -Exclude "de.txt", "en.txt"
or
Get-ChildItem "$InstallDir\Lang" -EXCLUDE "es.txt", "de.txt"| Remove-Item
These both work fine.
Whereas
Get-ChildItem "$InstallDir\Lang\*" -Exclude "$Language" | remove-item
does not work.
I tried several ways ( e.g. How to use Get-ChildItem with filter array in Powershell? or How to exclude list of items from Get-ChildItem result in powershell?) but I can“t find a solution.
It seems as if $Language
can't be interpreted by the command.
This is how $language
is built:
[string]$Language = @('"de.txt"')
If ($PackageConfigFile.Language -notlike $Null) {
foreach ($LIP in $PackageConfigFile.Language) {
$Language += ",`n ""$LIP.txt"""
}
}
$language has e.g. the following content
"de.txt",
"en.txt",
"es.txt"
Has anybody an idea?