This script provides an example of publishing an MSI application into the Windows Server Update Services (WSUS) server. Note that such “locally published” content will not be visible in the WSUS UI, so you need to call appropriate WSUS APIs in order to approve it and get compliance reports.

For detailed instructions on local publishing, see Local Publishing of Updates and Applications on MSDN.

PowerShell
Edit|Remove
# Warning: The publish operation will create a cab from everything in the
# packagepath directory (recusively). Do *not* point to a file in the root of
# your C:\ drive or your entire disk will be cab’ed (!). Make sure the setup
# file (and all files it needs) are in their own directory 

$packagepath = “C:\PackageDir\setup.msp”
$title = “MyPackage” # The title of the package
$description = “I’m publishing my own package – cool” # Description of package
 [reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") | out-null
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer();
$sdp = new-object('microsoft.updateservices.administration.SoftwareDistributionPackage')
$sdp.PopulatePackageFromWindowsInstallerPatch($packagepath)
$sdp.Title = $title
$sdp.Description = $description
$sdpFilePath = $env:temp + “\” + $title + $sdp.PackageId
$sdp.Save($sdpFilePath)
$publisher = $wsus.GetPublisher($sdpFilePath)
$dir = (new-object("System.IO.FileInfo")($packagepath)).Directory
$publisher.PublishPackage($dir, $null)