Hi @Pasam Pradeep Sabarinadh , Welcome to Microsoft Q&A,
Windows Update API (Windows Update Agent API
) provides more detailed patch information (such as KB number, installation status, time, etc.)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace xxx
{
class Program
{
static void Main(string[] args)
{
Type updateSessionType = Type.GetTypeFromProgID("Microsoft.Update.Session");
dynamic updateSession = Activator.CreateInstance(updateSessionType);
dynamic updateSearcher = updateSession.CreateUpdateSearcher();
try
{
dynamic searchResult = updateSearcher.Search("IsInstalled=1");
foreach (var update in searchResult.Updates)
{
Console.WriteLine($"Title: {update.Title}");
Console.WriteLine($"KB Article: {update.KBArticleIDs[0]}");
Console.WriteLine($"Installed Date: {update.LastDeploymentChangeTime}");
Console.WriteLine(new string('-', 50));
}
}
catch (Exception ex)
{
Console.WriteLine("Error retrieving Windows updates: " + ex.Message);
}
}
}
}
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.