簡體   English   中英

日期后有關已應用Windows更新的PowerShell報告

[英]PowerShell report on applied windows updates after a date

我試圖獲取有關從給定日期開始通過SCCM v12在Windows Server 2003和2008服務器上安裝了哪些Windows更新的信息。 為此,我使用了PowerShell的Get-Hotfix cmdlet。

但是,我遇到了一個問題,現在將解釋:

Get-HotFix -ComputerName SERVER01 | where-object {$_.hotfixid -ne "file 1"}  | Select description,hotfixid,installedby,InstalledOn | sort installedon

返回修補程序,但不包含日期。 我知道這是一個問題,因此要解決此問題,您需要像這樣運行它:

Get-HotFix -ComputerName SERVER01 | where-object {$_.hotfixid -ne "file 1"}  | Select description,hotfixid,installedby,@{l="InstalledOn";e={[DateTime]::Parse($_.psbase.properties["installedon"].value,$([System.Globalization.CultureInfo]::GetCultureInfo("en-US")))}}  | sort installedon

然后,它最多返回日期。 因此,接下來我只想從某個日期開始安裝更新,因此我運行此操作。

$date = Get-Date '26/07/2013'

Get-HotFix -ComputerName SERVER01 | where-object {$_.hotfixid -ne "file 1"}  | where "InstalledOn" -gt $date  | Select description,hotfixid,installedby,@{l="InstalledOn";e={[DateTime]::Parse($_.psbase.properties["installedon"].value,$([System.Globalization.CultureInfo]::GetCultureInfo("en-US")))}} | sort installedon

但這不會返回任何更新或錯誤。 但是,我知道自此日期以來已應用了一些更新,因為我在第二條命令結果中看到了這些更新。

那么問題是我做錯了嗎? 還有通過SCCM的另一種方法嗎?

Get-HotFix -ComputerName SERVER01 | where-object {$_.hotfixid -ne "file 1"} | Select description,hotfixid,installedby,@{l="InstalledOn";e={[DateTime]::Parse($_.psbase.properties["installedon"].value,$([System.Globalization.CultureInfo]::GetCultureInfo("en-US")))}} | where-object {$_.installedon –gt $date} | sort installedon -descending

我認為您可能將事情復雜化了:

get-hotfix | Where-Object {$_.installedon -gt (get-date).addmonths(-2)} | Sort-Object -property installedon -Descending

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM