使用PowerShell按特定日期列出Windows更新 [英] Listing Windows Updates by a Specific date using PowerShell

查看:67
本文介绍了使用PowerShell按特定日期列出Windows更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建/更新更新服务器的故障单。  我想让PowerShell用户获取特定日期的更新列表。  

Create/update trouble tickets for updating servers.  I want to user PowerShell to get a list of the updates for a specific day.  

我发现了一些非常接近的事情并提出了这个问题:

I've found some things that were close and came up with this:

$ date =" 1/21/2014"

$ Session = New-Object -ComObject" Microsoft.Update.Session"

$ Searcher = $ Session.CreateUpdateSearcher()

$ historyCount = $ Searcher.GetTotalHistoryCount()

$ Searcher.QueryHistory(0,$ historyCount)| Where-Object {$ _。日期-gt $ date}  |选择对象标题,日期>更新.txt

$date = "1/21/2014"
$Session = New-Object -ComObject "Microsoft.Update.Session"
$Searcher = $Session.CreateUpdateSearcher()
$historyCount = $Searcher.GetTotalHistoryCount()
$Searcher.QueryHistory(0, $historyCount) | Where-Object {$_.Date -gt $date}  | Select-Object Title, Date > updates.txt

它有效*但*时间是格林威治标准时间。  

It works *but* the times are in GMT.  

如何让它们正确打印?

推荐答案

时间是标准数据时间。

The times are in standard datatime.

要获得6当地时间,请使用 Date.ToLocalTime()

To get6 local time use Date.ToLocalTime()


Searcher.QueryHistory(0,
Searcher.QueryHistory(0,


historyCount)|

      Where-Object {
historyCount) |
      Where-Object {


这篇关于使用PowerShell按特定日期列出Windows更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆