≡ Menu

PowerShell : Query WSUS Server Database(SUSDB) Details

Today I got some requirement to verify the database name and DB server details of WSUS servers. This configuration is available inside HKLM\Software\Microsoft\Update Services\Server\Setup registry key of each WSUS server. So, I can query this registry value to find out what is the name of WSUS DB and DB server.

But out of curiosity, I started looked at the WSUS API that Boe Prox demonstrated in several articles on Script Guys blog as well as his personal blog. In past I have used this API query several other information like members of a WSUS group, patch approval status, and other information. So I thought it should have the DB details as well.

Luckily, I got what I need in few minutes. The root WSUS API object itself is having a method called GetDatabaseConfiguration which can return SUSDB and Database server details.

I wrapped this method inside a small function and I got what I need. Below is the sample code if you want to query this information.

function Get-WSUSDBDetails {            
[cmdletbinding()]            
param(            
[string]$WSUSServer            
)            

[void][reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")            
$WSUSObj = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($WSUSServer,$False)            
$WSUSObj.GetDatabaseConfiguration()            

}

Happy learning…

{ 0 comments… add one }

Leave a Comment