Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

System.__ComObject. How to retrieve the value

$
0
0

Hi, pretty new to powershell.. hoping for help with a little problem :) .. i was testing running windows update as below:

$Searcher = New-Object -ComObject Microsoft.Update.Searcher
$Results = $Searcher.search("Type='software' AND IsInstalled = 0")
$Results.Updates

..this will output the values of every object, and i thought of processing the data to a listview and from then make a template by checking the updates to install.

With the following code below, i will get the KB-value:
$results.Updates | Select-Object @{Name="KBArticleIDs"; Expression={$_.KBArticleIDs}}

..but with code that suites my usage better, i only get "System.__ComObject"

$Results.Updates | ForEach-Object {
$UpdateID = $_.Identity.UpdateID.ToString()
$KBArticleIDs = $_.KBArticleIDs.ToString()
...etc code here...
}

... so my question is, how do i get $KBArticleID as a string value ? ($_.Identity.KBArticleIDs does not do the trick).

Also, if someone could elaborate the behaviour, it would be appreciated :)

 

 

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles