UPDATED: Windows Server 2012 – WSUS Post-Install Tasks Fail Immediately

UPDATE:  The Original post was done on May 1, 2014. I’ve added script code at the bottom of the post to accommodate issues that may be encountered with WID conflicts in Server 2012/ 2012R2. The PS Script code also works with Server 2016.

Not long ago, I was trying to re-install WSUS on a server that would not generate the ‘WSUS Administration’ website.

Post-installation tasks would also fail without giving me much to go on. After some time researching, I found several posts on message boards that all said to do different things to resolve the issue. Some of them even said to either reload the OS on the server (not always an option in a production environment), or call Microsoft for help (which as we all know costs $$$).

Here’s what I found…

In the installation log located in the %temp% folder there should be a log file with the .TMP file extension. (EXAMPLE: tmp56B7.tmp)

When looking at this file, it told me that a file it was looking for was not found, or corrupt.

When I ran the WSUS Console I saw the following:

___________________________________________________________________________

The WSUS administration console has encountered an unexpected error. This may be a transient error; try restarting the administration console. If this error persists,

Try removing the persisted preferences for the console by deleting the wsus file under %appdata%\Microsoft\MMC\.

The WSUS administration console has encountered an unexpected error. This may be a transient error; try restarting the administration console. If this error persists,

Try removing the persisted preferences for the console by deleting the wsus file under %appdata%\Microsoft\MMC\.

System.NullReferenceException — Object reference not set to an instance of an object.

Source

Microsoft.UpdateServices.UI.AdminApiAccess

Stack Trace:

at Microsoft.UpdateServices.UI.AdminApiAccess.AdminApiTools.GetLocalInstallDir()

at Microsoft.UpdateServices.UI.AdminApiAccess.Constants..cctor()

** this exception was nested inside of the following exception **

System.TypeInitializationException — The type initializer for ‘Microsoft.UpdateServices.UI.AdminApiAccess.Constants’ threw an exception.

Source

Microsoft.UpdateServices.UI.SnapIn

Stack Trace:

at Microsoft.UpdateServices.UI.SnapIn.Scope.RootScopeNode.GetComputerTargetFromCmdLine()

at Microsoft.UpdateServices.UI.SnapIn.Scope.RootScopeNode.AddServerScopeNodeFromCmdLine()

at Microsoft.UpdateServices.UI.SnapIn.Common.SnapInManager.OnLoadCustomData(AsyncStatus status, Byte[] persistenceData)

___________________________________________________________________________

To resolve the issue, I performed the following steps (in order):

1) Open a PowerShell session as Administrator and uninstall WSUS completely with the following command:

Remove-WindowsFeature –Name UpdateServices,UpdateServices-DB,UpdateServices-RSAT,UpdateServices-API,UpdateServices-UI –IncludeManagementTools

2) Delete the registry key HKLM\SOFTWARE\Microsoft\Update Services

3) Delete the WSUS file from %appdata%\Microsoft\MMC

4) Delete the Folder %ProgramFiles%\Update Services along with all of its subfolders and files.

5) Reboot the server

6) Run the System File Checker to find and repair any inconsistencies by typing the command below into the PowerShell prompt.

SFC /scannow

7) Reboot the server

8) Verify IIS is installed and working without errors

9) Open a Powershell session as Administrator an install WSUS with the following command:

To use a SQL DB:

Install-WindowsFeature –Name UpdateServices,UpdateServices-DB -IncludeManagementTools

To use WID:

Install-WindowsFeature –Name UpdateServices –IncludeManagementTools

10) Once WSUS installation has completed, change the current working directory to %programfiles%\Update Services\Tools and run one of the following post-installation commands:

To use a SQL DB:

.\wsusutil.exe postinstall SQL_INSTANCE_NAME=”SERVER\Instance” CONTENT_DIR=”:\WSUS”

To use WID:

.\wsusutil.exe postinstall CONTENT_DIR=”:\WSUS”

11) Wait for the command to complete successfully.

12) If you are using this WSUS instance as part of a farm, then open the Admin Console and configure your updates.

13) If you are using this instance as part of the roles within an SCCM Implementation, open the SCCM Console and install the Software Update point role.


Here is my PowerShell Script code to perform the WSUS Installation and Post-Installation tasks. Copy the code and save it as a .PS1 script file and run it on the intended Server.

For use with SQL Server:

# Usage:
#       For named SQL Instances - 
#       .Install-WSUS.ps1 -SQLInstance "SQLservername\InstanceName" -ContentDir "DriveLetter:\FolderName"
#
#       For Default SQL Instance -
#       .Install-WSUS.ps1 -SQLInstance "SQLservername" -ContentDir "DriveLetter:\FolderName"

Param(
[Parameter(Mandatory=$True)][String]$SQLInstance,
[Parameter(Mandatory=$True)][String]$ContentDir
)

Install-WindowsFeature -Name UpdateServices -Verbose
Remove-WindowsFeature UpdateServices-WidDb -Verbose
Install-WindowsFeature -Name UpdateServices-DB -Verbose
Install-WindowsFeature -Name UpdateServices-UI -Verbose
Start-Process -FilePath "$($env:ProgramFiles)\Update Services\Tools\wsusutil.exe" -ArgumentList "postinstall SQL_INSTANCE_NAME=$($SQLInstance) CONTENT_DIR=$($ContentDir)" -Verbose -Wait

 

For use with Windows Internal Database:

# Usage:
#       .Install-WSUS.ps1 -ContentDir "DriveLetter:\FolderName"
Param(
[Parameter(Mandatory=$True)][String]$SQLInstance,
[Parameter(Mandatory=$True)][String]$ContentDir
)

Install-WindowsFeature -Name UpdateServices -Verbose
Install-WindowsFeature -Name UpdateServices-UI -Verbose
Start-Process -FilePath "$($env:ProgramFiles)\Update Services\Tools\wsusutil.exe" -ArgumentList "postinstall CONTENT_DIR=$($ContentDir)" -Verbose -Wait

Configure WSUS as needed and happy patching!

12 thoughts on “UPDATED: Windows Server 2012 – WSUS Post-Install Tasks Fail Immediately

  1. Install-WindowsFeature –Name UpdateServices,UpdateServices-DB -IncludeManagementTools gives me the following error:

    1. Feature WID Database has a conflict with the features Database.
    2. Feature Database has a conflict with the features WID Database.
    At line:1 char:1

    Like

    1. I have an updated script to install WSUS that I will be posting soon. It uninstalls the roles and features, then removes WID, then installs DB. For some reason MS seems to have changed the installation logic and rules with an update for Server 2012/ 2012 R2 somewhere along the line.

      Like

  2. I think the space between UpdateServices, and UpdateServices-DB in the command

    Install-WindowsFeature –Name UpdateServices, UpdateServices-DB -IncludeManagementTools

    has to be removed. Before removing it it was giving the errors

    Feature WID Database has a conflict with the features Database.
    Feature Database has a conflict with the features WID Database.

    JP

    Like

Leave a Reply to Paul Allen Cancel reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s