View Single Post
Old 10-02-2008   #2 (permalink)
Shay Levy [MVP]
Guest


 
 

Re: Powershell, WSUS, Execute Multiple Approvals per client computer

Hello jmedd,


I was able to run this and get results:



[void][reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")


$updateServer = "updateServerName"
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($updateServer,$false)

$computerScope = new-object Microsoft.UpdateServices.Administration.ComputerTargetScope
$computerScope.includedInstallationStates = "Installed,NotInstalled"

$updateScope = new-object Microsoft.UpdateServices.Administration.UpdateScope
$updateScope.includedInstallationStates = "Installed,NotInstalled"


$wsus.getComputerTargets($ComputerScope) | foreach {

$machine = $_
$fdn = @{n="FullDomainName";e={$machine.fullDomainName}}

$_.getUpdateInstallationInfoPerUpdate($updateScope) | foreach {
$updateId = $wsus.getUpdate($_.updateId)
$updateId | select $fdn,Title,UpdateType,IsApproved,IsDeclined,KnowledgebaseArticles
}
}



Here's the first item output:

FullDomainName : serverName.domain
Title : Cumulative Security Update for Outlook Express for
Windows Server 2003 (KB929123)
UpdateType : Software
IsApproved : True
IsDeclined : False
KnowledgebaseArticles : {929123}



HTH

---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Toolbar: http://tinyurl.com/PSToolbar


j> I need to approve around 100 updates for a client computer in WSUS.
j> Using the WSUS console for this is impracticle since its involves
j> about 5 - 6 clicks per update, so naturally I am looking to
j> Powershell for a solution.
j>
j> There are some sample scripts for managing WSUS 3.0 at the script
j> center.
j>
j> http://www.microsoft.com/technet/scr...us/server/defa
j> ult.mspx?mfr=true
j>
j> Basically what I need to do is for a particular computer find which
j> updates need approving and then approve them all for a particular
j> WSUS computer group in one go.
j>
j> So far I have:
j>
j> [reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.
j> Administration") | out-null
j> if (!$wsus) {
j> $wsus =
j> [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer
j> ();
j> }
j>
j> $wsus.GetComputerTargets()
j>
j> This basically returns a lot of info about the computers, but nothing
j> to do with approvals.
j>
j> Similarly the following gives you a load of info about the updates
j> including whether they are approved or not, but does not tell you
j> which group they are approved for.
j>
j> [reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.
j> Administration") | out-null
j> if (!$wsus) {
j> $wsus =
j> [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer
j> ();
j> }
j>
j> $updateScope = new-object
j> Microsoft.UpdateServices.Administration.UpdateScope;
j> $updateScope.UpdateApprovalActions =
j> [Microsoft.UpdateServices.Administration.UpdateApprovalActions]::Inst
j> all `
j> -bor
j> [Microsoft.UpdateServices.Administration.UpdateApprovalActions]::Unin
j> stall
j> $wsus.GetUpdates($updateScope)
j>
j> Exchanging the last line for
j>
j> $wsus.GetUpdateApprovals($updateScope)
j>
j> gets you some approval info, but not quite what I'm looking for.
j>
j> Anyone willing to assist would be most appreciated.
j>


My System SpecsSystem Spec