Automating Update Server Synchronization in VMM 2012(Part 2 of 2)

Greetings, this is part 2 of a 2 part series on the Update Management feature in VMM 2012.  The first post in this series is located on the SCVMM Blog.

In the Update Management feature for VMM 2012 synchronization of the Update Server with WU/MU catalog is handled on-demand.  In more detail, to initiate an Update Server Synchronization a VMM administrator invokes the Synchronize Update Server action.  When this action is invoked VMM 2012 initiates a call to the Update Server. The Update Server, which is the WSUS Server VMM is using, invokes a synchronization with the WU/MU catalog hosted on the Internet.  Once the WSUS server completes the synchronization VMM 2012 imports the incremental changes into it’s database.  Customers have reported the desire to automate the synchronization of the  Update Server on a schedule.  Leveraging the power of System Center Orchestrator and VMM Cmdlets this can be accomplished.   The following blog will detail how to develop a PowerShell script  based on VMM 2012 Cmdlets to automate the Update Server synchronization using SCORCH 2012.

Note: The blog also leverages the use of Servicing Windows in VMM 2012, but this is optional as synchronization of a catalog is a system related task this normally does not require a servicing window.


All scripts referenced in this blog can be downloaded from the Script Center.

1.       SCVMM Environment Pre-requisite:

-       Windows PowerShell v2.0 installed on VMM server

          Update Server added to VMM 2012

          Create Servicing Window record by name – SWForUpdateSync – to schedule update server synchronization


2.       PowerShell Script Reference:

         VMMUpdateServerSync.ps1 – Main script implementing the Update Server Synchronization scenario

          VMMUpdateutil.ps1 – Common script implementing common functions used in the main script

          VMMScriptRunFromSCORCH.ps1 – Script to run the Main script from remote machine or SCORCH workflow


3.       Automation flow:

          PowerShell script (VMMUpdateServerSync.ps1) performs following operations :

Ø  Check current time is within the Servicing Window time or not

Ø  Perform Update Server synchronization using VMM cmdlet – Start-SCUpdateServerSynchronization

Ø  Check the submitted VMM Job progress and log the status in file of form – VMMUpdateServerSyncyyyyMMddHHmmss.txt

          Create SC Orchestrator workflow or use Windows Task Scheduler to schedule executing the  powershell script at a specified time


4.       PowerShell Script Pre-requisite:

          Create following directories on a machine to install the script :

Ø  C:\SCVMM\UpdateAutomation (Copy all the scripts here)

Ø  C:\SCVMM\UpdateAutomation\Output (Output from script run is created here)

Note: For changing the directory names modify the Main script file.

Location to modify:



5.       PowerShell Script – Parameter Options:



6.       PowerShell Script Execution Types:

          From SCVMM Console:

Ø  Copy the following two scripts to SCVMM Library share and execute the script from VMM Console (e.g – Library -> MSCVMMLibrary -> Scripts -> VMMUpdateServerSync.ps1 -> Run)

²  VMMUpdateServerSync.ps1

²  VMMUpdateutil.ps1

Note: Change the parameter values in Main script to run the script directly on VMM console


          From PowerShell prompt on a remote machine installed with SCVMM console

Ø  Copy the following two scripts to the directory mentioned in Powershell Script Pre-requisite section and run the main script :

²  VMMUpdateServerSync.ps1

²  VMMUpdateutil.ps1

Ø  Execute the command using following syntax :

²  Powershell <Path To Script>\ VMMUpdateServerSync.ps1 <VMM Server Name> <Domain User> <Password>


          From Powershell prompt on a remote machine not installed with SCVMM console

Ø  Copy the following three scripts to the directory mentioned in Powershell Script Pre-requisite section on a remote machine :

²  VMMUpdateServerSync.ps1

²  VMMUpdateutil.ps1

²  VMMScriptRunFromSCORCH.ps1

Ø  Ensure powershell ver. 2.0 is installed on SCVMM server and enable PSRemoting

²  Enable-PSRemoting

Ø  Execute the following command to run the Main script from remote machine

²  powershell <Path To Script>\VMMScriptRunFromSCORCH.ps1 –VMMServer <VMMServer> -DomainUser <DomainUser> -Password <Password> -ScriptFile VMMUpdateServerSync.ps1


          From SC Orchestrator workflow

Ø  Create a workflow to trigger the Main script either directly or through Remote script

Ø  To trigger the powershell script use .Net script object in the workflow

Ø  Sample property setting for .Net script object:

²  General: SCVMM Update Server Sync

²  Details: Language Type: Powershell, In the script window copy the Remote script (VMMScriptRunFromSCORCH.ps1)

²  Parameters : Set the parameters (VMMServer, DomainUser, Password, ScriptFile) in the script to match the environment. Set ScriptFile=VMMUpdateServerSync.ps1.

Ø  Use Scheduler object to run the workflow at regular intervals recursively

Ø  Add other workflow objects as required

Ø  Sample Orchestrator workflow image:





Wrapping Up

We hope you find the scripts useful to automate the patching feature of SCVMM. The scripts are supplied to demonstrate the flexibility in integrating the System Center products and automating the in-box features. Customize the add value solution to meet your Datacenter requirement for patching and increase the operational efficiency. Please feel free to submit feedback through the Connect site and ask questions on the VMM forums.   Also, make sure to visit the VMM 2012 TechNet Library!


KR Kandavel (MSFT)