Cleanup WSUS with PowerShell

Use this script to cleanup WSUS server. I schedule it to run once each week:

$Port = "8530"
$Name = "WSUS"
$LogFile = "C:\WSUS_server_cleanup_log.txt"
Get-Date | Tee-Object -file $LogFile
Get-WsusServer -PortNumber $Port -Name $Name | Invoke-WsusServerCleanup -CleanupObsoleteComputers | Tee-Object -file $LogFile -append
Get-WsusServer -PortNumber $Port -Name $Name | Invoke-WsusServerCleanup -CleanupUnneededContentFiles | Tee-Object -file $LogFile -append
Get-WsusServer -PortNumber $Port -Name $Name | Invoke-WsusServerCleanup -CleanupObsoleteUpdates | Tee-Object -file $LogFile -append
Get-WsusServer -PortNumber $Port -Name $Name | Invoke-WsusServerCleanup -DeclineExpiredUpdates | Tee-Object -file $LogFile -append
Get-WsusServer -PortNumber $Port -Name $Name | Invoke-WsusServerCleanup -DeclineSupersededUpdates | Tee-Object -file $LogFile -append
Get-WsusServer -PortNumber $Port -Name $Name | Invoke-WsusServerCleanup -CompressUpdates | Tee-Object -file $LogFile -append
Get-Date | Tee-Object -file $LogFile -append

Kommentarer

Populære opslag fra denne blog

Microsoft Office 2016 and the AUTO_ACTIVATE property

Access Exchange online with Office 365 multi-factor authentication (MFA/2FA)

Disable logon and logoff events (event id 4624, 4625, 4634 (and all the other ones...))