Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Approve patches in WSUS by powershell

$
0
0

Hi

I want use powershell to approve patches from specific date to specific WSUS group. I wrote a script:

$kb = $wsus.getupdates() | where {$_.CreationDate -eq '3/13/2012 5:00:00 PM'} | select -exp KnowledgebaseArticles
$group = $wsus.GetComputerTargetGroups() | where {$_.Name -eq 'TestGroup'}
$i = 0
foreach($k in $kb)
{
    $update = $wsus.SearchUpdates($k)
    $update[$i].approve("Install",$group)   
    ++$i    
}

But it add only one patch and output error:

You cannot call a method on a null-valued expression.
At line:7 char:24
+     $update[$i].approve <<<< ("Install",$group)   
    + CategoryInfo          : InvalidOperation: (approve:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

How can I modify to make it work?


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>