【问题标题】:How do I search wildcard files in mount points with Powershell?如何使用 Powershell 在挂载点中搜索通配符文件?
【发布时间】:2014-05-12 11:42:34
【问题描述】:

我正在尝试获取挂载点子目录中的所有 *.log 文件。

Command: [IO.Directory]::GetDirectories('e:\')

正在向我显示所有目录;如何在这些子目录中搜索 *.log 文件?

【问题讨论】:

    标签: powershell mount-point


    【解决方案1】:
    get-childItem e:\ -recurse -Filter *.log
    

    对于您的示例,我认为您可以这样做:

    $alldirs=ls E: -recurse -directory
    
    $alldirs|%{ 
        $nb=(ls -filter *.log).count
        if ($nb -gt $WARNING){
            "This Folder $_ is having > $nb < *.log files   "
        }
    }
    

    【讨论】:

    • 谢谢...这有帮助,但我在 msdn 上得到了这个脚本。我在物理驱动器上工作,但不是在挂载点上工作。你可以看看这个吗? social.technet.microsoft.com/Forums/systemcenter/de-DE/…
    • 你到底想做什么? get-childitem 在挂载点内工作正常...
    • 这是脚本。它在物理驱动器上运行良好,但如果 e: 有挂载点,则搜索将不起作用: $DATASTORE = "E:\" $WARNING=1 $ALLFOLDERS = [System.IO.Directory]::GetDirectories($DATASTORE ,"","AllDirectories") foreach ($ALLFOLDERS 中的$Folder) { $ANZAHL= ([System.IO.Directory]::GetFiles($Folder,".log","TopDirectoryOnly" )).count if ($ANZAHL -gt $WARNING) { "这个文件夹 $Folder 有 > $ANZAHL
    • 对不起,我不知道如何添加源代码。 :-(
    猜你喜欢
    • 2014-12-09
    • 2020-11-01
    • 2011-02-03
    • 2011-03-21
    • 2010-12-07
    • 2022-06-24
    • 1970-01-01
    • 1970-01-01
    • 2019-05-10
    相关资源
    最近更新 更多