-
Notifications
You must be signed in to change notification settings - Fork 0
/
windows-updates.ps1
55 lines (43 loc) · 1.96 KB
/
windows-updates.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#https://github.com/brandontylerstevens/BrandonTylerStevens-PowerShell/tree/Main/Windows%20Updates
# Stolen by Brandon Stevens
Function Build-CVEReport {
### Install the module from the PowerShell Gallery (must be run as Admin)
Install-Module -Name msrcsecurityupdates -force
Import-module msrcsecurityupdates
Set-MSRCApiKey -ApiKey "1bd79db501ce49a5ae1a117a2de252c8" -Verbose
$culture = New-Object system.globalization.cultureinfo(“en-US”)
Get-MsrcCvrfDocument -ID "$((get-date).Year)-$(($culture).DateTimeFormat.GetAbbreviatedMonthName(((get-date).Month)))" | Get-MsrcSecurityBulletinHtml -Verbose | Out-File C:\Windows\Temp\MSRCSecurityUpdates-$(($culture).DateTimeFormat.GetAbbreviatedMonthName(((get-date).Month))).html
#Get-MsrcCvrfDocument -ID "$((get-date).Year)-Jun" | Get-MsrcSecurityBulletinHtml -Verbose | Out-File C:\Windows\Temp\MSRCSecurityUpdates.html
}
Build-CVEReport
$computers = 'server1',"server2"
Function Get-LastUpdateInfo
{
param(
[parameter(Mandatory)]
[string[]]$computerName,
[int]$Months=-6)
$date = (get-date).AddMonths($Months)
$monthPositive = $Months * -1
$propName = "UpdatedWithin"+$monthPositive+"Months"
$hotfixes = $computerName |
ForEach-Object {
Get-HotFix -ComputerName $_ | Sort-Object installedon -Descending |
Select-Object -First 1
}
$hash = @{
name = $propName
expression = {
if ($_.InstalledON -le $date)
{
$false
}
elseif(($_.InstalledON -gt $date))
{
$true
}
}
}
$hotfixes | Select-Object CSName,InstalledON,$hash
}
Get-LastUpdateInfo -computerName $computers -Months -3