{"id":2439,"date":"2014-08-19T12:41:41","date_gmt":"2014-08-19T11:41:41","guid":{"rendered":"http:\/\/www.edwardsd.co.uk\/work\/?p=2439"},"modified":"2017-09-20T21:15:58","modified_gmt":"2017-09-20T20:15:58","slug":"saving-windows-disk-space-wsus-scheduled-server-cleanup-wizard","status":"publish","type":"post","link":"https:\/\/www.edwardsd.co.uk\/work\/2014\/08\/saving-windows-disk-space-wsus-scheduled-server-cleanup-wizard\/","title":{"rendered":"WSUS | Saving Windows Disk Space | Scheduled &#8220;Server Cleanup Wizard&#8221;"},"content":{"rendered":"<p>This script will automatically run the &#8220;WSUS Server Cleanup Wizard&#8221;<br \/>\nThis can be added to a scheduled task.<\/p>\n<p><!--more--><\/p>\n<pre lang=\"powershell\">#Region VARIABLES\n\n# WSUS Connection Parameters:\n## Change settings below to your situation. ##\n# FQDN of the WSUS server\n[String]$parentServer = \"UK-SVS-WSUS01\"\n# Use secure connection $True or $False\n[Boolean]$useSecureConnection = $False\n[Int32]$portNumber = 8530\n# From address of email notification\n[String]$emailFromAddress = \"UK-SVS-WSUS01@domain.com\"\n# To address of email notification\n[String]$emailToAddress = \"WSUS Cleanup Results: UK-SVS-WSUS01\"\n# Subject of email notification\n[String]$emailSubject = \"UK-SVS-WSUS01@domain.com\"\n# Exchange server\n[String]$emailMailserver = \"smtp.domain.com\"\n# Cleanup Parameters:\n## Set to $True or $False ##\n# Decline updates that have not been approved for 30 days or more, are not currently needed by any clients, and are superseded by an aproved update.\n[Boolean]$supersededUpdates = $True\n# Decline updates that aren't approved and have been expired my Microsoft.\n[Boolean]$expiredUpdates = $True\n# Delete updates that are expired and have not been approved for 30 days or more.\n[Boolean]$obsoleteUpdates = $True\n# Delete older update revisions that have not been approved for 30 days or more.\n[Boolean]$compressUpdates = $True\n# Delete computers that have not contacted the server in 30 days or more.\n[Boolean]$obsoleteComputers = $True\n# Delete update files that aren't needed by updates or downstream servers.\n[Boolean]$unneededContentFiles = $True\n\n#EndRegion VARIABLES\n\n#Region SCRIPT\n\n# Load .NET assembly\n[void][reflection.assembly]::LoadWithPartialName(\"Microsoft.UpdateServices.Administration\");\n\n# Connect to WSUS Server\n$wsusParent = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($parentServer,$useSecureConnection,$portNumber);\n\n# Log the date first\n$DateNow = Get-Date\n\n# Perform Cleanup\n$Body += \"$parentServer ($DateNow ) :\" | Out-String\n$CleanupManager = $wsusParent.GetCleanupManager();\n$CleanupScope = New-Object Microsoft.UpdateServices.Administration.CleanupScope($supersededUpdates,$expiredUpdates,$obsoleteUpdates,$compressUpdates,$obsoleteComputers,$unneededContentFiles);\n$Body += $CleanupManager.PerformCleanup($CleanupScope) | Out-String\n# Send the results in an email\nSend-MailMessage -From $emailFromAddress -To $emailToAddress -Subject $emailSubject -Body $Body -SmtpServer $emailMailserver\n\n#EndRegion SCRIPT\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This script will automatically run the &#8220;WSUS Server Cleanup Wizard&#8221; This can be added to a scheduled task.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[18,23,44],"tags":[],"class_list":["post-2439","post","type-post","status-publish","format-standard","hentry","category-windows-server-2003","category-windows-server-2008","category-windows-server-2012"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pOPt8-Dl","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.edwardsd.co.uk\/work\/wp-json\/wp\/v2\/posts\/2439","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.edwardsd.co.uk\/work\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.edwardsd.co.uk\/work\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.edwardsd.co.uk\/work\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.edwardsd.co.uk\/work\/wp-json\/wp\/v2\/comments?post=2439"}],"version-history":[{"count":5,"href":"https:\/\/www.edwardsd.co.uk\/work\/wp-json\/wp\/v2\/posts\/2439\/revisions"}],"predecessor-version":[{"id":3338,"href":"https:\/\/www.edwardsd.co.uk\/work\/wp-json\/wp\/v2\/posts\/2439\/revisions\/3338"}],"wp:attachment":[{"href":"https:\/\/www.edwardsd.co.uk\/work\/wp-json\/wp\/v2\/media?parent=2439"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.edwardsd.co.uk\/work\/wp-json\/wp\/v2\/categories?post=2439"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.edwardsd.co.uk\/work\/wp-json\/wp\/v2\/tags?post=2439"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}