gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 22:47:38 25 4
gpt4 key购买 nike

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

远程计算机未安装 Powershell,因此 Powershell 远程处理已失效。 .NET 和 WMI 可用。我已成功使用 Advapi32.dll 中的 RegEnumKeyEx 函数来获取本地计算机上的 lpftLastWriteTime。

最佳答案

如何使用 LogParser,可从 Microsoft 获取?

下面是使用 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

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

关于powershell - 返回远程计算机上指定注册表项的 LastWriteTime,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6537346/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com