Synchronize WSUS with Powershell

Yesterday, I showed you how to script the WSUS Cleanup Wizard with Powershell. Today, the WSUS fun continues! Here’s how to use powershell to “manually” synchronize your WSUS server, i.e. download the latest updates.

#Region VARIABLES
 
# WSUS Connection Parameters:
[String]$updateServer = "myWSUSServer.domain.local"
[Boolean]$useSecureConnection = $False
[Int32]$portNumber = 80
 
#EndRegion VARIABLES
 
#Region SCRIPT
 
# Load .NET assembly
[void][reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")
 
# Connect to WSUS Server
$Wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($updateServer,$useSecureConnection,$portNumber)
 
# Perform Synchronization
$Subscription = $Wsus.GetSubscription()
$Subscription.StartSynchronization()
 
#EndRegion SCRIPT

Download the script here: Synchronize-Wsus (rename to .ps1)

Enjoy!
Hugo

  • Share/Bookmark

No related posts.

  • Roger Truss

    May 18th, 2009

    Thanks for the sync script. One question. Does it sync with Microsoft or an upstream server?

  • admin

    May 19th, 2009

    Whichever you configured the server to sync with. It does the same thing as clicking on Synchronize Now in the WSUS console.

  • No trackbacks yet

Leave a Comment

* are Required fields