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?