Skip to content

Commit

Permalink
Bug fixes (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
potatoqualitee authored Sep 14, 2022
1 parent 7a462eb commit 8f0b20e
Show file tree
Hide file tree
Showing 6 changed files with 213 additions and 43 deletions.
11 changes: 11 additions & 0 deletions build/updates.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ update kb set NetworkRequired = "No" where NetworkRequired = 0;
update kb set ExclusiveInstall = "No" where ExclusiveInstall = 0;
update kb set MSRCSeverity = null where MSRCSeverity = "n/a";

update kb set Architecture = null where Architecture = "n/a";
update kb set Architecture = "x64" where Architecture LIKE '%x64%';
update kb set Architecture = "x64" where Architecture LIKE '%AMD64%';
update kb set Architecture = "x64" where Architecture LIKE '%64%bit%';
update kb set Architecture = "ARM64" where Architecture LIKE '%ARM64%';
update kb set Architecture = "ARM32" where Architecture LIKE '%ARM%based%';
update kb set Architecture = "ARM32" where Architecture LIKE '%ARM32%';
update kb set Architecture = "x86" where Architecture LIKE '%x86%';
update kb set Architecture = "x86" where Architecture LIKE '%32%bit%';
update kb set Architecture = null where architecture NOT IN ('x64','x86','IA64','ARM64','ARM','ARM32');

DELETE FROM Link
WHERE EXISTS (
SELECT 1 FROM Link p2
Expand Down
2 changes: 1 addition & 1 deletion kbupdate.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ if (-not $IsLinux -and -not $IsMacOs) {
}

# Register autocompleters
Register-PSFTeppScriptblock -Name Architecture -ScriptBlock { "x64", "x86", "ia64", "ARM" }
Register-PSFTeppScriptblock -Name Architecture -ScriptBlock { "x64","x86","IA64","ARM64","ARM","ARM32" }
Register-PSFTeppScriptblock -Name OperatingSystem -ScriptBlock { "Windows Server 2022", "Windows Server 2019", "Windows Server 2016", "Windows 10", "Windows 8.1", "Windows Server 2012 R2", "Windows 8", "Windows Server 2012", "Windows Server 2012 Hyper-V", "Windows 7", "Windows Server 2008 R2", "Windows Vista", "Windows Server 2008", "Windows Small Business Server (SBS) 2008", "Windows Server 2003", "Windows Small Business Server (SBS) 2003", "Windows XP", "Windows XP Media Center Edition (MCE)", "Windows XP Tablet PC Edition", "Windows 2000", "Small Business Server (SBS) 2000", "Windows NT 4.0", "Windows Millennium Edition (ME)", "Windows 98 Second Edition (SE)", "Windows 98", "Windows 95", "Microsoft Windows Update", "Windows Embedded Compact 2013", "Windows Embedded Compact 7", "Windows Embedded CE 6.0", "Windows CE 5.0", "Windows CE .NET 4.2", "Windows CE .NET 4.1" }
Register-PSFTeppScriptblock -Name Product -ScriptBlock { "Exchange Server 2019", "Exchange Server 2016", "Exchange Server 2013", "Exchange Server 2010", "Exchange Server 2007", "Exchange Server 2003", "Exchange Server 2000", "Exchange Server 5.5", "Exchange Server 5.0", "Exchange Server 4.0", "Microsoft Office 365", "Outlook 2019", "Excel 2019", "Word 2019", "Access 2019", "Outlook 2016", "Excel 2016", "Word 2016", "Access 2016", "Outlook 2013", "Excel 2013", "Word 2013", "Access 2013", "Outlook 2010", "Excel 2010", "Word 2010", "Access 2010", "Outlook 2007", "Excel 2007", "Word 2007", "Access 2007", "PowerPoint 2007", "Visio 2007", "Publisher 2007", "Project 2007", "OneNote 2007", "InfoPath 2007", "Microsoft Office Groove 2007", "Outlook 2003", "Excel 2003", "Word 2003", "Access 2003", "PowerPoint 2003", "FrontPage 2003", "Visio 2003", "Publisher 2003", "Project 2003", "OneNote 2003", "InfoPath 2003", "Outlook 2002 (Outlook XP)", "Excel 2002 (Excel XP)", "Word 2002 (Word XP)", "Access 2002 (Access XP)", "PowerPoint 2002 (PowerPoint XP)", "FrontPage 2002 (FrontPage XP)", "Visio 2002 (Visio XP)", "Publisher 2002 (Publisher XP)", "Project 2002 (Project XP)", "Outlook 2000", "Excel 2000", "Word 2000", "Access 2000", "PowerPoint 2000", "FrontPage 2000", "Visio 2000", "Publisher 2000", "Project 2000", "Microsoft Office Live Meeting 2005", "Microsoft Works Suite 2003", "Microsoft Works Suite 2002", "Microsoft Works Suite 2001", "Microsoft Works 2000", "SharePoint Server 2019", "SharePoint Server 2016", "SharePoint Server 2013", "SharePoint Server 2010", "SharePoint Server 2007", "SharePoint Portal Server 2003", "SharePoint Portal Server 2001", "BizTalk Server 2006", "BizTalk Server 2004", "BizTalk Server 2002", "BizTalk Server 2000", "Internet Security and Acceleration (ISA) Server 2006", "Internet Security and Acceleration (ISA) Server 2004", "Internet Security and Acceleration (ISA) Server 2000", "System Center Essentials (SCE) 2010", "System Center Essentials (SCE) 2007", "System Center Operations Manager (SCOM) 2012", "System Center Virtual Machine Manager (SCVMM) 2012", "System Center Orchestrator (SCO) 2012", "System Center Service Manager (SCSM) 2012", "System Center Configuration Manager (SCCM) 2012", "System Center Configuration Manager (SCCM) 2007", "Systems Management Server (SMS) 2003", "Systems Management Server (SMS) 2.0", "Systems Management Server (SMS) 1.2", "Systems Management Server (SMS) 1.1", "Systems Management Server (SMS) 1.0", "SNA Server 4.0", "SNA Server 3.0", "System Center Operations Manager (SCOM) 2007", "Operations Manager (MOM) 2005", "Operations Manager (MOM) 2000", "Host Integration Server (HIS) 2004", "Host Integration Server (HIS) 2000", "Commerce Server 2007", "Commerce Server 2002", "Commerce Server 2000", "Dynamics CRM 3.0", "Zune", "Xbox 360", "Internet Explorer 11", "Internet Explorer 10", "Internet Explorer 9", "Internet Explorer 8", "Internet Explorer 7", "Internet Explorer 6", "Internet Explorer 5.5", "Internet Explorer 5.0", "SQL Server 2017", "SQL Server 2016", "SQL Server 2014", "SQL Server 2012", "SQL Server 2008 R2", "SQL Server 2008", "SQL Server 2005", "SQL Server 2000", "SQL Server 7.0", "Microsoft Data Access Components (MDAC) 2.8", "Microsoft Data Access Components (MDAC) 2.7", "Microsoft Data Access Components (MDAC) 2.6", "Microsoft Data Access Components (MDAC) 2.5", "Microsoft Data Access Components (MDAC) 2.1", "Visual FoxPro 9.0", "Visual FoxPro 8.0", "Visual FoxPro 7.0", "Visual FoxPro 6.0", ".NET Framework 4.7", ".NET Framework 4.6", ".NET Framework 4.5", ".NET Framework 4", ".NET Framework 3.5", ".NET Framework 3.0", ".NET Framework 2.0", ".NET Framework 1.1", ".NET Framework 1.0", "ASP.NET 2.0", "ASP.NET 1.1", "ASP.NET 1.0", "Visual Studio 2008", "Visual Studio 2005", "Visual C++ 2005", "Visual C# 2005", "Visual Basic 2005", "Visual Studio .NET 2003", "Visual C++ .NET 2003", "Visual C# .NET 2003", "Visual Basic .NET 2003", "Visual Studio .NET 2002", "Visual C++ .NET 2002", "Visual C# .NET 2002", "Visual Basic .NET 2002", "Visual Studio 6.0", "Visual C++ 6.0", "Visual Basic 6.0", "Windows Media Player 11", "Windows Media Player 10", "Windows Media Player 9", "Internet Information Services (IIS) 7.0", "Internet Information Services (IIS) 6.0", "Internet Information Services (IIS) 5.1", "Internet Information Services (IIS) 5.0", "Office Accounting 2007", "Small Business Accounting 2006", "Money 2007", "Money 2006", "Money 2005", "Money 2004", "Money 2003", "Money 2002", "Money 2001", "Visual SourceSafe 6.0", "Microsoft Encarta Encyclopedia 2000", "Age of Empires III (AoE3)", "Age of Empires II (AoE2)", "Age of Mythology", "Zoo Tycoon 2", "Zoo Tycoon", "Microsoft Mail for Appletalk Networks 3.1", "Microsoft Mail for Appletalk Networks 3.0" }
# Languge is a tough one
Expand Down
18 changes: 17 additions & 1 deletion private/Update-KbDatabase.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,22 @@ function Update-KbDatabase {
$arch = "x86"
}

if ($arch -eq "n/a") {
$arch = $null
}
if ($link -match "x64" -or $link -match "AMD64") {
$arch = "x64"
}
if ($link -match "x86") {
$arch = "x86"
}
if ($link -match "ARM64") {
$arch = "ARM64"
}
if ($link -match "ARM-based") {
$arch = "ARM32"
}

$detaildialog = Invoke-TlsWebRequest -Uri "https://www.catalog.update.microsoft.com/ScopedViewInline.aspx?updateid=$updateid"
$description = Get-Info -Text $detaildialog -Pattern '<span id="ScopedViewHandler_desc">'
$lastmodified = Get-Info -Text $detaildialog -Pattern '<span id="ScopedViewHandler_date">'
Expand Down Expand Up @@ -431,7 +447,7 @@ function Update-KbDatabase {
$null = Install-Module kbupdate-library -ErrorAction Stop -Scope CurrentUser
$null = Import-Module kbupdate-library -ErrorAction Stop
}
$modpath = Split-Path (Get-Module kbupdate-library).Path
$modpath = Split-Path (Get-Module kbupdate-library).Path | Select-Object -Last 1
$kblib = Join-PSFPath -Path $modpath -Child library
$db = Join-PSFPath -Path $kblib -Child kb.sqlite

Expand Down
9 changes: 6 additions & 3 deletions public/Get-KbNeededUpdate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,15 @@ function Get-KbNeededUpdate {
}
$searcher = $wua.CreateUpdateSearcher()
Write-Verbose -Message "Searching for needed updates"
$wsuskbs = $searcher.Search("IsAssigned=1 and IsHidden=0 and IsInstalled=0")
$wsuskbs = $searcher.Search("Type='Software' and IsHidden=0")
Write-Verbose -Message "Found $($wsuskbs.Count) updates"

foreach ($wsu in $wsuskbs) {
foreach ($wsuskb in $wsu.Updates) {
#isinstalled didnt work as expected for me in the searcher
if ($wsuskb.IsInstalled) {
continue
}
# iterate the updates in searchresult
# it must be force iterated like this
$links = @()
Expand All @@ -118,7 +122,6 @@ function Get-KbNeededUpdate {
}
}
}

[pscustomobject]@{
ComputerName = $Computer
Title = $wsuskb.Title
Expand All @@ -141,7 +144,7 @@ function Get-KbNeededUpdate {
Supersedes = $null #TODO
SupersededBy = $null #TODO
Link = $links
InputObject = $wsu
InputObject = $wsuskb
}
}
}
Expand Down
20 changes: 14 additions & 6 deletions public/Get-KbUpdate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function Get-KbUpdate {
Filters out any patches that have been superseded by other patches in the batch
.PARAMETER Force
When using Latest, the Web is required to get the freshest data unless Force is used.
When using Latest, the Web is required to get the freshest data unless Force is used. Also when Force is used, the cache is ignored.
.PARAMETER Exclude
Exclude matches for pattern
Expand Down Expand Up @@ -284,8 +284,12 @@ function Get-KbUpdate {
$script:allresults += $guid
$hashkey = "$guid-$Simple"
if ($script:kbcollection.ContainsKey($hashkey)) {
$script:kbcollection[$hashkey]
continue
if ($Force) {
$script:kbcollection.Remove($hashkey)
} else {
$script:kbcollection[$hashkey]
continue
}
}
$severity = $wsuskb.MsrcSeverity | Select-Object -First 1
$alert = $wsuskb.SecurityBulletins | Select-Object -First 1
Expand Down Expand Up @@ -505,9 +509,13 @@ function Get-KbUpdate {
$itemtitle = $item.Title
$hashkey = "$guid-$Simple"
if ($script:kbcollection.ContainsKey($hashkey)) {
$guids = $guids | Where-Object Guid -notin $guid
$script:kbcollection[$hashkey]
continue
if ($Force) {
$script:kbcollection.Remove($hashkey)
} else {
$guids = $guids | Where-Object Guid -notin $guid
$script:kbcollection[$hashkey]
continue
}
}
}

Expand Down
Loading

0 comments on commit 8f0b20e

Please sign in to comment.