Quantcast
Channel: WSUS forum
Viewing all articles
Browse latest Browse all 12874

WSUS Powershell Report

$
0
0

Hello,

I've got a script which replicates a report in WSUS itself and it's working perfectly fine; however I'd like an additional one which runs the report but only on a specific Group/Groups

Below is the script

[void][reflection.assembly]::LoadWithPartialName(“Microsoft.UpdateServices.Administration”)
$wsus =[Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer(“server”,$false, '8530')

$computerscope = New-Object Microsoft.UpdateServices.Administration.ComputerTargetScope
$updatescope = New-Object Microsoft.UpdateServices.Administration.UpdateScope

$workstationsGroup = $wsus.GetComputerTargetGroups()
$computerscope.IncludeSubgroups = $true
$computerscope.IncludeDownstreamComputerTargets = $true

$updatescope.ApprovedStates = [Microsoft.UpdateServices.Administration.ApprovedStates]::LatestRevisionApproved
$updatescope.ExcludeOptionalUpdates = $true
$updatescope.UpdateSources = [Microsoft.UpdateServices.Administration.UpdateSources]::MicrosoftUpdate

$d = Get-Date -format yyyy_MM_dd

$wsus.GetSummariesPerComputerTarget($updatescope,$computerscope) |
    Select-Object @{L='Computer'; E={($wsus.GetComputerTarget([guid]$_.ComputerTargetId)).FullDomainName}},
        @{L=’NeededCount’;E={($_.DownloadedCount +   $_.NotInstalledCount)}},DownloadedCount,NotInstalledCount,FailedCount,InstalledCount,NotApplicableCount | where {$_.NeededCount -gt 0} |
        Export-Csv -NoClobber -NoTypeInformation -Path S:\WSUS_Scheduled_Tasks\Needed_Updates\Report_$($d).csv

I read online and it says I need to put a where pipe on line 7, so I put this

$workstationsGroup = $wsus.GetComputerTargetGroups() | where {$_.Name -eq "ServerGroup"}

The report runs but it's still searching the entire WSUS and not just computers in that group.

Do I need to put the where statement somewhere else in the script?


Viewing all articles
Browse latest Browse all 12874

Trending Articles



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