返回远程计算机上指定注册表项的LastWriteTime

Sha*_*aun 5 powershell powershell-2.0

使用Powershell,如何枚举远程计算机上指定注册表项的LastWriteTime?

远程机器没有安装Powershell,因此Powershell远程控制已经完成..NET和WMI可用.我已成功使用Advapi32.dll中的RegEnumKeyEx函数在本地计算机上获取lpftLastWriteTime.

nim*_*zen 2

使用Microsoft提供的 LogParser 怎么样?

下面是使用 COM 对象的代码示例:

$query = @"

    SELECT 
        Path, 
        KeyName, 
        ValueName, 
        Value, 
        LastWriteTime 
    INTO $outfile 
    FROM \\remotecomputername\HKLM\etc\etc
    WHERE LastWriteTime BETWEEN 
        TIMESTAMP('2011/08/01 00:00:00', 'yyyy/MM/dd hh:mm:ss') AND 
        TIMESTAMP('2011/09/06 00:00:00', 'yyyy/MM/dd hh:mm:ss') 
    ORDER BY LastWriteTime DESC

"@

$inputtype = New-Object -comObject MSUtil.LogQuery.RegistryInputFormat
$outputtype = New-Object -comObject MSUtil.LogQuery.CSVOutputFormat
$outfile = 'c:\temp\outfile.csv'
$logObject = new-object -com MSUtil.LogQuery
$result = $logObject.ExecuteBatch($query, $inputtype, $outputtype) | Out-Null
Run Code Online (Sandbox Code Playgroud)

如果需要,您可以在 FROM 子句中提供多个以逗号分隔的值来查询多台计算机。进一步阅读此处