Return LastWriteTime of the specified registry key on the remote computer

Using Powershell, how can I list LastWriteTime of a specified registry key on a remote computer?

Powershell is not installed on the remote computer, so Powershell..NET and WMI are disabled. I successfully used the RegEnumKeyEx function in the Advapi32.dll file to get lpftLastWriteTime on the local machine.

+5
source share
1 answer

How about using LogParser, available from Microsoft ?

And here is a sample code using a COM object:

$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 , . .

+1

All Articles