Wednesday, June 30, 2021

Windows: Reset WSUS and recreate SUSDB

Here are the steps if you have installed WSUS on Server 2012R2 on the Windows Internal Database to reset the Database and WSUS itself.


Install the Microsoft SQL 2012 Management Studio.

Install SQL-Management Studio
Install SQL-Management Studio

Determine the SQL Server String, Database name and the WSUS Content Directory







c:\> reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Update Services\Server\Setup" /v SqlServerName
    SqlServerName    REG_EXPAND_SZ    MICROSOFT##WID
c:\> reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Update Services\Server\Setup" /v SqlDatabaseName
    SqlDatabaseName    REG_SZ    SUSDB
c:\> reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Update Services\Server\Setup" /v ContentDir
    ContentDir    REG_EXPAND_SZ    D:\WSUS

Stop all WSUS related services (World Wide Web Publishing Service, WSUS Certificate Server and WSUS Service)




c:\> net stop W3SVC
c:\> net stop WsusService
c:\> net stop WSusCertServer

Start SQL Management Studio as Administrator (right click) and
Connect to the Windows internal Database through the named pipe \\.\pipe\Microsoft##WID\tsql\query

Connect to Windows internal Database  by SQL-Management Studio
Connect to Windows internal Database by SQL-Management Studio

And delete the SUSDB




ALTER DATABASE SUSDB
SET OFFLINE WITH ROLLBACK IMMEDIATE;
DROP DATABASE SUSDB;

Delete the Database files



c:\> del /Q C:\Windows\WID\Data\SUSDB.*
c:\> del /Q C:\Windows\WID\Data\SUSDB_*.*

Remove the existing Content Dirctory


c:\> rmdir /Q /S D:\WSUS

Reconfigure WSUS, Create SUSDB and a new content Directory


c:\> "C:\Program Files\Update Services\Tools\wsusutil.exe" postinstall CONTENT_DIR="D:\WSUS"

If the error “Fatal Error: Failed to start and configure the WSUS service” occured try to start the WSUS Service manually



c:\> net start WsusService
c:\> net start WSusCertServer

 

1 comment: