Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

WSUS via PowerShell - Find update file location

$
0
0

I am writing a script to cleanup wsus more in depth.

 

I need the command to find the update file location on the WSUS server

From my research I belleive it should be something like Update.FileUri however I cannot get this to return any results

 

Code so far

[reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer();

$approveState = 'Microsoft.UpdateServices.Administration.ApprovedStates' -as [type]

$updateScope = New-Object Microsoft.UpdateServices.Administration.UpdateScope -Property @{
    ApprovedStates = $approveState::Declined
}
$Declined = $wsus.GetUpdates($updateScope)| Where {$_.IsSuperseded -eq $True -or $_.PublicationState -eq "Expired"}
#Write-Host $Declined.count
If ($Declined.count -GT 0) {
    $Counter = 0
    $Declined | ForEach-Object {
    $Counter = $Counter + 1
    Write-Host $Counter of $Declined.count $_.Title $_.FileUri
    }
    }
Else
{
Write-Host No updates Fount to Remove
}


Viewing all articles
Browse latest Browse all 6937

Trending Articles