Powershell:将多个AND过滤器添加到复制项

时间:2020-07-27 15:54:02

标签: powershell copy-item

我想在-Filter中为复制项使用多个AND条件,但目前似乎没有任何作用。

示例:循环浏览文件夹并提取带有日期和名称的任何文件。问题是它们在路径上并不相邻,两者之间是唯一的。 示例文件名:2020-07-27 _ @ $#@ $#@ $ @ __ ABCConstruction

当前在代码中有效,但是仅使用日期,我想添加AND / ||。到-Filter,但每次都会引发错误。

    function Logs {
        if(Test-Path "\\${server}\D`$\Log\${whatClient}" -PathType Container){
            Copy-Item -Path "\\${server}\D`$\Log\${whatClient}\*" -Filter "*${whatDate}*" -Destination "i:\log\Powershell\${whatEnvironment}_${whatClient}_${logType}_${whatDate}" -Recurse
            $fileCount = (Get-ChildItem "\\${server}\D`$\Log\${whatClient}" -Filter "*${whatDate}*" | Measure-Object).Count
        }
        "$server contained $fileCount files."   
    }

0 个答案:

没有答案
相关问题