1

对于事件查看器,我想要事件树中每个条目的默认视图配置。这些 channel_i.xml 根据树形结构存储在文件夹中的 $env:ProgramData\Microsoft\Event Viewer 下。可悲的是,似乎没有将 Logname 映射到其配置文件位置的标准行为。有没有得到这个的功能?目标语言环境是德语。目前我正在使用一个自定义函数,如果找不到,则哈希表中的所有异常都会返回原始字符串。主要代码是

Get-WinEvent -ListLog * | % {
    if($windows.Contains($_.LogName)){
        writeFile $builtin (localize $_.LogName)
    }else{
        $components = $_.Logname.Split("/")
        if($components.Count -gt 1) { 
            $name = $components[1] 
            $components= $components[0].Split("-")
        }else{
            [System.Collections.ArrayList]$components= $components[0].Split("-")
            $name = $components[-1]
            $components.RemoveAt($components.Count-1)
        }
        if($components.Count -gt 2){
            $components = $components[0..1] +($components[2..($components.Count-1)] -join "-")
        }
        $path = localize ($components -join "\")
        WriteFile "$app\$path" (localize $name)
    }    
}

完整代码可以在https://pastebin.com/Cn4JSmLL下找到

4

0 回答 0