Synchronize WSUS Replica (slave) Server from the Command Line

Scripting guru Torgeir Bakken’s response;

Torgeir Bakken (MVP):

It is easy to create this command line utility yourself. WSUS expose .NET API’s that can be called from VB.NET, C#.NET, or other .NET languages.

The easiest way to develop .NET programs is to use Visual Studio, but VS is not required. The .NET Framework ships with all the basic tools necessary for building .NET programs.

To get a tool that starts a WSUS synchronization, do the following on the WSUS server:

1) Copy the code below and save it to a text file named
“StartSynchronization.vb”

2) Open a command prompt, and navigate to the directory containing
StartSynchronization.vb.

3) Run the following command line (all one one line, you will need to
unwrap the line before running it!):

%WINDIR%\Microsoft.NET\Framework\v1.1.4322\vbc.exe
  StartSynchronization.vb /r:”%PROGRAMFILES%\Update Services\
service\bin\Microsoft.UpdateServices.Administration.dll”
  /out:StartSynchronization.exe


This will create a tool called StartSynchronization.exe that when run
will start a WSUS synchronization.

Content of StartSynchronization.vb:
——————–8<———————-

Imports Microsoft.UpdateServices.Administration

Module StartSynchronization

     Sub Main()
         Dim server As IUpdateServer
         Dim subscription As ISubscription

         ‘connect to the local server
         server = AdminProxy.GetUpdateServer

         subscription = server.GetSubscription()
         subscription.StartSynchronization()

     End Sub

End Module

——————–8<———————-

More WSUS API information/examples:

“Windows Server Update Services API Samples and Tools” is available for
download here:

http://www.microsoft.com/windowsserversystem/updateservices/downloads…

and

Platform SDK: Windows Server Update Services
http://msdn.microsoft.com/library/en-us/wus/wus/portal.asp

Leave a Reply

Your email address will not be published. Required fields are marked *