Tyl*_*r N 2 windows windows-registry windows-update powershell
设置中的 Windows 更新页面包含一个Last Checked时间戳,我试图确定是否有可能以某种方式查询机器以获取此信息(通过命令提示符、PowerShell、注册表查询等)
我搜索了Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate我的注册表的一部分,发现没有与我的Last Checked.
有没有办法查询这个?目标是能够查询远程计算机的信息,以避免必须远程访问它。
运行 PowerShell 命令$(New-Object -ComObject Microsoft.Update.AutoUpdate).Results.LastSearchSuccessDate返回具有匹配日期但时间不匹配的时间戳
按照建议,LastSearchSuccessDate使用 (.NET) 函数将返回的 UTC 时间转换为您的本地时间:
Function Get-LocalTime($UTCTime) {
$strCurrentTimeZone = (Get-WmiObject win32_timezone).StandardName
$TZ = [System.TimeZoneInfo]::FindSystemTimeZoneById($strCurrentTimeZone)
Return [System.TimeZoneInfo]::ConvertTimeFromUtc($UTCTime, $TZ)
}
Get-LocalTime $(New-Object -ComObject Microsoft.Update.AutoUpdate).Results.LastSearchSuccessDate
Run Code Online (Sandbox Code Playgroud)
给我的结果与“检查更新”用户界面中显示的结果相同。
Invoke-Command -ComputerName $server -ScriptBlock {
Function Get-LocalTime($UTCTime) {
$strCurrentTimeZone = (Get-WmiObject win32_timezone).StandardName
$TZ = [System.TimeZoneInfo]::FindSystemTimeZoneById($strCurrentTimeZone)
Return [System.TimeZoneInfo]::ConvertTimeFromUtc($UTCTime, $TZ)
}
Get-LocalTime $(New-Object -ComObject Microsoft.Update.AutoUpdate).Results.LastSearchSuccessDate
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
94 次 |
| 最近记录: |