Hello everyone!
Let me start with saying I am currently trying to learn more advanced PowerShell scripting and have been taking a few courses on MVA and reading many forums. Typically I try to leverage the built-in help system to find my answer by using Get-Member and such for properties / objects and their syntax. However, I am in need for this fairly simple script sooner than later for some auditing procedures I need to take care of. I had found most of this script below on one of the many forums I frequent, but cannot remember which. The script does have all of the information I am looking for, and believe that the objects it calls on has the property I am looking for. I just haven’t been able to figure out how to extract just the KB number ( KB123456789 ) itself and create it’s own column. I have slightly modified the original code and cleaned it up to make it easier for me to understand and posted it below. Again, I know it provides it to me in the Title section, but I need it to be on it’s own as well. Any guidance would be greatly appreciated!
$Session = New-Object -ComObject "Microsoft.Update.Session";
$Searcher = $Session.CreateUpdateSearcher();
$historyCount = $Searcher.GetTotalHistoryCount();
$Searcher.QueryHistory(0, $historyCount) |
Select-Object Date,
@{name="Operation";
expression={
switch($_.operation){
1 {"Installation"};
2 {"Uninstallation"};
3 {"Other"}
}
}
},
@{name="Status";
expression={
switch($_.resultcode){
1 {"In Progress"};
2 {"Succeeded"};
3 {"Succeeded With Errors"};
4 {"Failed"};
5 {"Aborted"}
}
}
},
Title,
Description