is update approved for specific group via powershell?


hello, 

i have script auto approves updates based on release date specific groups. script checks see if update has been approved (e.g. isapproved) , either skips if it's been approved or approves specific group (e.g. $update.approve("install",$wsus_group)). problem i'm running if approve update1 groupa, later check update1's isapproved see whether or not need approve groupb, update1's isapproved $true , therefor script skips approving groupb. i've checked update's object , don't see multi-valued var groups been approved for. i've started poke around other microsoft.updateservices.administration namespaces don't see 1 has info i'm looking for. 

so, how can view updates have been approved groupa vs groupb?

thanks! 

hi joey,

if want approve updates multiple groups, , want check if updates have been approved groups, please check script below:

can examine 1 computergroup , find updates not approved 1 or multiple other computer groups.

$servername="localhost" $targetcomputergroup="baselinegroup" $checkformissing="missinggroup1,missinggroup2"  [void][reflection.assembly]::loadwithpartialname("microsoft.updateservices.administration") $wsus=[microsoft.updateservices.administration.adminproxy]::getupdateserver($servername,$false) $computergroup=$wsus.getcomputertargetgroups()|foreach-object -process {if ($_.name -eq $targetcomputergroup) {$_}} $updatescope=new-object microsoft.updateservices.administration.updatescope $updatescope.approvedstates="any" $updatescope.approvedcomputertargetgroups.add($computergroup) $approvals = $wsus.getupdateapprovals($updatescope)  #at point have of updates assigned $targetcomputergroup  $report= @() write-host "querying updates approved $targetcomputergroup"  foreach ($approval in $approvals) {    $record=""|select-object computergroup,updatename, updateid    $record.computergroup=$wsus.getcomputertargetgroup($approval.computertargetgroupid).name    $record.updatename=$wsus.getupdate($approval.updateid).title    $record.updateid=$wsus.getupdate($approval.updateid).id.updateid    $report +=$record    }  #now group results updatename $gr=$report|group -property updatename  $checkformissing=$checkformissing.split(",")   foreach ($entry in $gr) {     $groups=@()     foreach ($g in $entry.group) {         $groups += $g.computergroup         }     foreach ($missing in $checkformissing) {         if ($groups -contains $missing) {}         else{             new-object psobject -property @{             name = $entry.name             updateid = $entry.group[0].updateid             groupmissing = $missing             }         }     } }

reference from:

wsus report approvals group

i hope helps.



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Schannel Issue

Indexing Server

oclist /xml or /?