Version 3.2 to 3.5 (Released 2018.06.01)
- Re-branding of Adamj Clean-WSUS to AJTek’s WSUS Automated Maintenance (WAM) ©
- Added info to HelpMe
- Altered the entire script into a multi-file system, extracting each function, SQL script, and logic part into its own file.
- Manipulated the new SQL Scripts to adhere to the new system as some were being dynamically generated. Created parameter passing in these instances, condensing some of the SQL scripts.
- Expanded InstallTask to auto-create on systems running Server 2012 and lower that cannot create scheduled tasks through PowerShell using SchTask.exe instead.
- Expanded InstallTask’s SQL script on remote systems to include the code for previous versions of SQL (2005-2008) for adding the computer object’s account to the db_owner group.
- Created single installer for the entire system that allows for easy auto-configuration.
- Added ‘LOCALHOST’ as part of the possible SQL Server auto-detections, rather than just the <ComputerName>
- Bug Fix: DeclineMultipleTypesOfUpdates – The XP search was just searching ‘XP’ which was also triggering on eXPerience and others. Changed it to search for ‘ XP’ instead.
- Added Sharepoint Updates and ARM64 updates to the list of DeclineMultipleTypesOfUpdates.
- Added a frequency to DeclineMultipleTypesOfUpdates of either Daily or Monthly, for each individual set.
- Adjusted the RemoveObsoleteUpdates and CompressUpdateRevisions to run daily.
- Updated the URL Link to Microsoft KB Articles as Microsoft had changed this.
- Added AJTekSupersededUpdateDeclineAfterDays to allow for a delay of declining superseded updates. Thank you Brian Gleason for giving me this feature.
- Added -ErrorAction Stop to Get-WsusClassification which is what usually errors out if run on Server 2008.
- Bug Fix: Test-SQLConnection – added required escaped double quotes around the SqlServerName to account for non-standard SQL Server Ports (server,port). Thank you michaelschuler on Spiceworks for giving me this fix.
- Modified RemoveObsoleteUpdates and CompressUpdateRevisions to have better output including current time and delta times for each removal or compression.
- Re-configured DirtyDatabaseCheck to bring the queries and process more inline with Microsoft’s newest official method located on the KB3194588 page.
- Deprecated DirtyDatabaseCheck as Microsoft has changed the way they do things (for the better). It is still possible that you may need to run this switch but know that this will ALWAYS return a Dirty Database now due to the way Microsoft changed things.
- Re-enabled the erroring out of the script if the Automatic detection of the SQL Server fails to connect, which technically shouldn’t happen anymore.
- Renamed Prerequisites to System Requirements and re-adjusted the organization of the file accordingly. Made it easier to differentiate between what is recommended and minimum requirements.
- Added a configurable option for always displaying the WSUS DB Maintenance output in detail, rather than just on the ScheduledRunStreamsDay.
- On -SetApplicationPoolMemory, after changing the application pool memory, added a check to see if the application pool was in the stopped state and either started or restarted the application pool depending on what is required at the time.
- Added a check to see if the script times out while getting updates from the server into a variable. If this happens, it will continue on with the SQL queries to clean up and run the maintenance and will also alert you (in the console as well as in the log file) to re-run the -FirstRun switch up to 15 times. The idea is that the SQL queries will remove and optimize the database enough such that eventually getting all of updates from the server into a variable will be successful.
Version 3.1 to 3.2 (Released 2017.11.10)
- Bug Fix: Dirty Database Fix SQL Script to 1.1 – Added use SUSDB.
- Added EULA.
Version 3.0 to 3.1 (Released 2017.09.16)
- Spelling error on DirtyDatabaseCheck in ‘.EXAMPLE’.
- Clarify using apostrophes in the AdamjMailReportSMTPServerPassword variable.
- Prerequisite update to might need to change the encoding to ANSI – now that I’ve removed any non-ASCII Character in the script.
- Corrected English on DeclineMultipleTypesOfUpdates if using -FirstRun so that it says ‘today’ rather than the scheduled streams number.
- Bug Fix: Change $AdamjWSUSServer to check to see if it’s part of a domain, and if so, add the domain, otherwise use the hostname.
- Bug Fix: Revert Drivers SQL Removal back to 1.0 – 1.1 was causing errors killing the script from running.
Version 2.11 to 3.0 (Released 2017.09.01)
- NOTICE TO PREVIOUS USERS: Updated the description for RemoveDeclinedWSUSUpdates. Please read it.
- Added Test-IfBlocked – If it’s blocked, it will unblock it.
- Changed the behaviour of -InstallTask to remove the ExecutionPolicy as it will be auto-unblocked.
- BUG FIX: Changed -InstallTask to work with 6.2 which is Server 2012.
- Added DirtyDatabaseCheck – Checks to see if your database is in a bad state. If it’s in a bad state it fixes it.
- Changed WSUS Server variables to automatically pull from the registry entries. It should be fully automatic now for 99% of all cases.
- Added AdamjScriptVersion primarily for the -HelpMe stream for easier version recognition.
- Added DeclineMultipleTypesOfUpdates to replace DeclineSupersededUpdates.
- Changed -IncreaseApplicationPoolMemory to -SetApplicationPoolMemory and made it allow 0 (unlimited) or a higher number.
- Rewrote the prerequisites for SBS for clarity.
- Rewrote the .DESCRIPTION, organized the description of the streams by how they are run, with manual ones at the bottom.
- Rewrote the Install-Task function and added it to -FirstRun.
- Replaced some double quotes into single quotes around the script.
- Re-designed the SQL Testing and created it to auto-detect from the Windows Registry. It should be fully automatic now for 99% of all cases.
- Added a bypass for the -HelpMe stream if it can’t connect to the WSUS Server, it will bypass and create the log file for help.
- Added WSUSIndexOptimization stream which will increase the speed of WSUS’s database processing by 1000-1500 times faster.
- Added options for running RemoveWSUSDrivers in FirstRun and in the other routines.
- Clarified the Remote SQL Server instructions with the scheduled task running. Thank you to Ross Anderson for the full solution instructions.
- On Remote SQL Databases, setup the Scheduled Task to run as NT AUTHORITYSYSTEM and add the DOMAINCOMPUTER$ account to db_owner on only the SUSDB database.
- Added fix for spaces in the file or path name with regards to creating the scheduled task.
- Expanded the RemoveWSUSDriversSQL script to version 1.1 by adding new tables to check/resolve issues from.
- Ran some regular expression searches to remove any non-ASCII characters within the script and remove trailing tabs and spaces.
Version 2.10 to 2.11 (Released 2017.05.11)
- Re-organized Run switches.
- Added a Restart of the Application pool if you increase the application pool to make sure the settings take effect.
- Added logic to not connect to the WSUS server if not actually running something that requires it (Display & Increase the application pool and InstallTask).
- Added a configuration value for $AdamjScheduledTaskTime.
- Added a ComputerObjectCleanup Stream for more control over computer object removals.
- Cleaned up old commented code and spacing.
- Added and changed some commented code to verbose output.
Version 2.09 to 2.10 (Not Released)
- Added the Adamj Application Pool Memory Configuration Stream.
- Added information about Server 2016 at the prerequisites stage.
- Added Start-Transcript to -HelpMe stream as now everything is outputted to objects, not just Write-Host.
- Added Show-MyFunctions and Show-MyVariables and added them to the -HelpMe output instead of the contstraint to just Adamj Variables.
- Removed the Clean Up Variables section at the end. Once the script finishes running all variables within the script are destroyed as none are set globally.
- Changed $AdamjWSUSServer to auto-populate vs manual entry, along with changing it to lowercase within the script.
- Added comments for Gmail settings.
- Added comments in the SQL Server Variable section for the auto-detect issue on Server 2008 (R2).
- Added an SBS Section to the prerequisites.
- Created a function for Connect-WSUSServer.
- Created a function for -InstallTask and a check for powershell version 4 or higher within. Adjusted the Instructions at the top.
Version 2.08 to 2.09 (Not Released)
- Added CompressUpdateRevisions and RemoveObsoleteUpdates SQL Scripts as MonthlyRun items along with FirstRun.
- Added Configuration for Mail Report and Save Report options.
- Added Donation links.
- Fixed bug with running script from a folder with a space.
Version 2.07 to 2.08 (Not Released)
- Re-adjusted all Write-Host to Write-Output.
- Changed $AdamjScriptPath from split-path -parent $MyInvocation.MyCommand.Definition to Split-Path $script:MyInvocation.MyCommand.Path.
- Changed $VerbosePreference to “Continue” when executing -HelpMe.
- Added Begin, Process, End operators.
- Setup -HelpMe to change VerbosePreference to continue and change it back at the end to what it was before.
- Changed Test-Administrator to streamline the process.
- Changed SQL-Ping-Instance to Test-SQLConnection and cleaned up the code.
- Added some VERBOSE output throughout the script.
- Fixed a bug with $ExceptionError in the RemoveDeclinedWSUSUpdatesProceed function.
- Adjusted the prerequesites and added SQL Cmd line tools requirement with links.
- Fixed a bug with RemoveDeclinedWSUSUpdates, thanks to Nikolay Semov (Nikolay8159) from the Spiceworks forums.
- Added regions to each section for ease of modification and readability in PowerShell ISE and other editors.
Version 2.06 to 2.07 (Released 2016.10.05)
- Adjusted the prerequisites wording for clarity regarding the ANSI encoding.
Version 2.05 to 2.06 (Released 2016.07.08)
- Added notes regarding a Remote SQL connection such that you must use the computer account to run the script via Schedule Tasks.
- Added a -HelpMe Stream for getting troubleshooting data for support reasons.
- Check for for replica server and exclude only the DeclineSupersededUpdates as you can only decline superseded updates from the upstream server. Thanks to Jurriaan van Doornik for the help with testing and investigating.
- Adjusted the Timeout on the SQL-Ping Function to 60 seconds only if you specify the $AdamjSQLServer variable.
- Altered the Versioning notes layout for clarity and separation.
- Added a prerequisite of ANSI encoding for troubleshooting.
- Adjusted some of the descriptions of the streams information text to be more clear and consistent.
- Spelling and grammar fixes.
Version 2.04 to 2.05 (Released 2016.03.17)
- Tested on Server 2008 SP2, Server 2008 R2, Server 2012, and Server 2012 R2.
- Came up with installation instructions for prerequisites.
- Added code for detecting last day of the month if $AdamjScheduledRunStreamsDay is greater than the last day of the month, including leap years for months less than 31 days.
- Thank you to Malil for the initial base of the code for checking for $AdamjScheduledRunStreamsDay
Version 2.03 to 2.04 (Not Released)
- Fixed issue with SQL Connection command for issues with connecting to a Windows Server 2008 Internal Database.
- Fixed some visual issues with the TXT output relating to the duration.
- Clarified some instructional text at the top.
Version 2.02 to 2.03 (Not Released)
- Properly formatted running time duration to hh:mm:ss
- Added calculated duration of each stream, and total script duration.
- Removed a duplicated value in the setup configuration
Version 2.01 to 2.02 (Not Released)
- Malil helped troubleshooting further and I made code changes for $AdamjSQLServer on Server 2008.
- Added better email logs for the RemoveWSUSDriversSQL Stream. Added console messages to show that the script is still working and what it is doing as this stream will take time. Added console error message summaries, and file/email error message details.
- Changed Quarterly months defaults to 1, 4, 7, 10.
Version 2.00 to 2.01 (Not Released)
- Troubleshooting help by Malil from Spiceworks forums which lead to 2 small but significant code changes for the auto-detection of the $AdamjSQLServer variable, provided by Malil.
- Fixed the SCW to also account for hours run, rather than just minutes and seconds.
Version 1.5 to 2.01 (Not Released)
- Changed the mail function to allow for authentication, SSL, and SMTP Port
- Cleaned up the ‘Clean Up Variables’ section to account for all Adamj* Variables
- Added Clean Up WSUS Synchronization Logs Stream to keep the Sync logs clean
- Added SQL Auto-detect with function help from (http://stackoverflow.com/questions/11540445/how-to-verify-whether-the-sql-server-instance-is-correct-or-not-using-powershell)
- Redesigned pretty much the entire script into a function driven script.
- Added cmdlet options for running each section manually, or by way of the recommended time periods (Daily, Monthly, Quarterly)
- Added error checking and throwing better error messages on various things.
- Added Test-Administrator to confirm it is being run with elevated rights.
- Updated the Prerequisites and Instructions sections.
- Updated the output of the SCW.
Version 1.3 to 1.5 (Released 2015.07.16)
- Added the Adamj Remove Drivers Stream, Adamj Remove Declined WSUS Updates Stream, and the Adamj WSUS DB Maintenance Stream. Renamed the Adamj Bonus Cleanup Stream to Adamj Decline Superseded Updates Stream.
- Changed the formulation of the script into modular form. Now the script has 5 modular streams:
- WSUS Server Cleanup Wizard Stream
- Adamj Remove WSUS Drivers Stream
- Adamj Remove Declined WSUS Updates Stream
- Adamj WSUS 3.0 DB Maintenance Stream
- Adamj Decline Superseded Updates Stream.
Version 1.2 to 1.3 (Released 2015.07.09)
- Added the $AdamjBonusCleanupUpdatesCount variable to the output line on the declining updates message, so that a copy/paste can easily be done that shows how many updates were declined when it actually declines them.
Version 1.1 to 1.2 (Released 2015.07.06)
- Created the Adamj Bonus Cleanup Stream. Changed the output email into HTML and formatted the output nicely.
- Thanks to Rob Dunn from the Spiceworks forums for reviewing the code and making some suggestions on the code to help enumerate information better.
Version 1.0 to 1.1 (Not Released)
- Added “Diskspace Freed (GB)” from example code https://p0w3rsh3ll.wordpress.com/2015/01/26/cleanup-wsus/
- Re-formatted output of the email.
Version 1.0 - Initial Release (Released 2015.01.30)