WindowsUpdateの更新可能なプログラムを検索する

WindowsUpdateの更新可能なプログラムを検索するスクリプトを作成しました。

Function ComRelease{
    param($obj);
    if ($obj -ne $null ){
        while([System.Runtime.InteropServices.Marshal]::ReleaseComObject($obj) -gt 0){}
    }
}

$sch = new-object -com Microsoft.Update.Searcher;
$res = $sch.Search("Type='Software'");
foreach ( $u in $res.Updates ) {
    if (!$u.IsInstalled){
        $u.title;
    }
}

ComRelease $sch;
ComRelease $res;
ComRelease $u;

以下が実行結果の例です。